Contrary to what some may believe, the Prophet Muhammad (peace be upon him) was a man who would occasionally joke with this companions. This, in itself, should come as no surprise if we were reflect on the fact that humour has the capacity warm people’s hearts and lift their spirits, it is most befitting that that a sense of humour be one of the characteristics possessed by the Prophet Muhammad (peace be upon him) along with the other characteristic required by the crucial role of Prophet.
Such a characteristic complimented wonderfully with the other qualities and roles required by a Prophet such as a teacher. As an example of this we may look towards a small event which took place in his life. One day, as he visited the home of Anas ibn Malik, he found Anas’ little brother looking as though he was sad and depressed. After enquiring of what had happened to him he was told that the little boy had been in a miserable mood ever since his pet bird died. When the little boy appeared again, the Prophet (peace be upon him) said: “Abu ‘Umayr, what did the little bird do?” whereupon the boy burst out laughing. 
The phraseology used by the Prophet (peace be upon him) in his question along with being a rhyming play on words in Arabic, it also has a has a very subtle humour as it starts with a solemn address and ends in an anticlimax. It is way, through use of humour, that the Prophet (peace be upon him) was able to teach this boy to accept life and death.
An important point, however, which one must realise is that although the Prophet (peace be upon him) would joke with his family and companions, and even laugh at their jokes, giving them friendly names or nicknames, he always behaved very sensibly and considerately and in accordance with the demands of good moral principles.
Aside from refraining completely from the kind of joking that may hurt another’s feeling, the Prophet (peace be upon him) never used to joke about that which was not true, likewise he instructed other not do so either saying “woe to the one who speaks and lies in order to make people laugh; woe to him, woe to him.” 
 Narrated by Al-Bukhari.
 Narrated by Abu Dawood, al-Tirmidhi and al-Nasaa’i with a good chain.
Al-Ismail, Tahia, The Life of Muhammad, Ta-Ha Publishers, London, UK, 1988. p.438-439.
Yahya, Harun, The Prophet Muhammad (people be upon him), Global Publishing, Istanbul, Turkey, 1999. P.103