Joking is desirable when it does not lead to sinful acts such as ridiculing or slander and only has the intention of making a brother in faith happy
That which can be derived from the etiquette and teachings of Islamic society and the way (Sunnah) of the Prophet Muhammad (peace be upon him) is that joking is desirable when it does not lead to sinful acts such as disparaging, ridiculing or slander and only has the intention of making a brother in faith happy. The Prophet, in addition to encouraging his companions to make jokes, would himself joke with them.
‘Ali ibn Abi-Talib (A.S) has said, "The Messenger of God (S.A.W.A), in order to make one of his companions happy who had been upset, would joke with him and he would say, 'Verily, God hates one who snarls in his brother's (in faith) face."
There are numerous instances of the Prophet's tendency to joke recorded in books of his traditions and lifestyle:
1. A servant of the Messenger of God named Anjashah would say "huda" (something they say to make a camel go faster) to the camel of the Prophet's wife. The Prophet said, "O Anjashah, be careful (when dealing) with glass” an allusion to the fact that women are fragile and it is possible that at a high speed they may get scared, fall and hurt themselves).
2. A women came to the Messenger and mentioned her husband's name. He asked, "Is your husband the one who has white in his eyes? She replied, "No, he doesn't have white in his eyes." When that woman went home and told her husband what had happened, he said, "Don't you see that the white part of my eyes is more than the black part?"
3. The Prophet's lifestyle was such that he permitted his supporters to say humorous things in his blessed presence. Following the example of the Prophet, they would stay away from inappropriate jokes. But they did not hold back when it came to acceptable forms of joking.
"Nu'ayman was the type of person who liked to joke. One day he saw a Bedouin with a sack of honey. He bought it and took it to the Prophet's house. The Messenger of God thought he had brought this as a gift. Nu'ayman left and the Bedouin came standing in front of the Prophet's house. After waiting for a long time, he yelled, 'Whoever lives here, if you don't have money, give the honey back.' The Messenger of God discovered what had happened and paid that man for the honey.
When the Prophet met Nu'ayman, he asked, 'Why did you do that?'
Nu'ayman said, 'I figured, the Messenger of God likes honey and that Bedouin man had a lot of honey.' The Messenger of God laughed at what Nu'ayman had done and did not show any signs of being upset. "