All perfect praise be to Allah, the Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad, sallallaahu ‘alayhi wa sallam, is His slave and Messenger.
The most important thing to say regarding the rationale behind the prohibition of killing some animals is that this is what the Sunnah came with. What the Prophet, sallallaahu ‘alayhi wa sallam, came with is part of the divine revelation; Allah, the Exalted, says (what means): {Nor does he speak from (his own) inclination. It is not but a revelation revealed.} [Quran 53:3-4]
Some scholars attempted to deduce the rationale behind the prohibition of killing them, including what the author of ‘Awn Al-Ma‘bood quoted from Al-Khattaabi who said:
“The prohibition of killing ants is particular to a type of large long-footed ants whose harm is minimal. As for the bees, it is prohibited to kill them because they are of benefit to humans, given that they produce honey and beeswax. As for the hoopoe and shrike, it is prohibited to kill them because their flesh is unlawful for human consumption. If it is prohibited to kill an animal not for the sake of preserving its life or because of the harm it involves, then it is because its flesh is unlawful to eat. It is said that the flesh of the hoopoe has a stench, so it is regarded as the Jallaalah (the animal that feeds on filth and impurities) - whose flesh is unlawful to eat - as such a foul diet causes the animal's flesh to smell bad.”
Allah knows best.