Islam encourages every good action and urges Muslims to show mercy to all the creatures of Allah, including birds and animals. Therefore, caging pet animals and offering food and water to them and treating them kindly is permissible.
Sheikh Salman Ibn Fahd Al-`Udah, states: “Based on many proofs of Shari`ah, it seems that it is permissible to keep an animal in a cage. Both Al-Bukhari and Muslim reported that the Prophet (peace and blessings be upon him) used to ask a little boy about a bird that he was keeping. [It is recorded that there was a boy at the time of the Prophet (peace and blessings be upon him) called Abu `Umayr and he used to keep a small bird with him all the time. Whenever he saw his family in the house, the Prophet (peace and blessings be upon him) used to call this boy, smile at him and say: “What has happened to An-Nughayr (the name of the bird)?” This behaviour of the Prophet (peace and blessings be upon him) indicates that it is permissible to keep birds at home and offer them food.]
Moreover, the Prophet (peace and blessings be upon him) said: “A woman entered Hell for locking up a cat until it died of starvation. She did not feed it, give it to drink, or let it have food elsewhere.” (Al-Bukhari and Muslim) In the above narration, the Prophet (peace and blessings be upon him) did not condemn the woman’s detention of the cat, but condemned her failure to give it food and drink. It is, therefore, obligatory for the one who wishes to keep an animal in the house to provide for it and care for it in the best possible manner.”