All perfect praise be to Allaah, The Lord of the worlds. I testify that there is none worthy of worship except Allaah and that Muhammad is His slave and Messenger.
Shaykh Dr. Saalih Al-Fawzaan was once asked a similar question: "We know the wisdom behind the adversities that befall the Muslim, as they may be trials or punishment for his mistakes. But what is the wisdom behind the afflictions that befall some animals and birds?"
He answered:
"The wisdom of Allaah in His creation cannot be fully comprehended by our limited minds; we may realize some aspects of the wisdom behind His actions and commands and we may fail to grasp others. However, we believe with certainty that whatever He does must have a meaningful purpose because His actions are never in vain; all of His actions are based on great wisdom. It is absolutely inconceivable that He creates anything in vain or legislates anything in jest. The afflictions that befall animals and birds may be trials or punishments for their owners; Allaah, The Exalted, says (what means): {And We will surely test you with something of fear and hunger and a loss of wealth and lives and fruits, but give good tidings to the patient, Who, when disaster strikes them, say, "Indeed we belong to Allaah, and indeed to Him we will return."} [Quran 2:155-156]"
Allaah knows best.