Because the chicken can feel pain.
https://abcnews.go.com/International/wireStory/germany-ban-practice-killing-newly-hatched-male-chicks-75368116
Methods are to be used with which the sex is already determined in the egg so that male chicks do not even hatch. From the year 2024, however, such methods should only be permitted if the sex of the chick is identified at a particularly early stage of the incubation. This should also avoid pain for the embryo in the future. https://www.tagesschau.de/inland/innenpolitik/bundestag-kuekentoetung-beschluss-101.html
The German Animal Welfare Association expressed joy at this suggestion, but criticized that this two-stage ban will not actually prohibit the killing of pain-sensitive chick embryos until 2024.
From 2024, the draft law will also require poultry famers to use methods that work at an earlier stage in the incubation process, preventing pain for the unhatched embryos.