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 is His slave and Messenger.
Sometimes the Prophet used to make jokes but he always used to say what is true and what is true only. Once he said to a woman “Is your husband the one whose eyes have whiteness?” She replied: “His eyes are good and healthy.” The Prophet meant the natural whiteness of the eye, which is around its pupil. The Prophet said: “Sometimes I make fun but I do not say except what is truth.” Imam Al-Munawi said in the explanation of the Prophet's saying above: “The Hadeeth means that his joke is based on truth whether it is an action or a saying, since he is protected from doing anything wrong.”
Once he said to an aged woman: “No aged woman will enter Paradise.” Then he explained to her that she will become young when she enters Paradise.
Once he said to a woman: “I will give you a child of a camel for riding.” She asked, “How can one ride on a child of a camel”; then he replied, “Every camel is a child of a camel.”
Somebody told Ibn ‘Uyayna (a well-known Muslim scholar): “Making fun is a shame.” He objected and said: “No, it is a Sunnah for who knows how to make it perfectly? The Prophet used to engage in fun and he is an example for people, and they are asked to follow his acts and deeds.”
Imam Al-Mawardi said: “An intelligent person makes fun for one of two reasons. First, to create a friendly atmosphere through good sayings and good acts. Second, to try to dispel tiredness as it is said that discharge is compulsory for the one whose chest is filled with anxieties. The Prophet's fun was not outside of these two reasons.
The Prophet used to make fair fun with the small brother of his companion Anas as narrated in Shaheeh Al-Bukhaari who said: “The Prophet was the best of all people in character. I had a brother called Abu ‘Umayr, who, I think, had been newly weaned. Whenever he (that child) was brought to the Prophet, the Prophet used to say, “O Abu ‘Umayr! What did An-Nughayr (nightingale) do? It was a nightingale with which he used to play.”
This Hadeeth shows that the Prophet used to make fun with this child, so one may make fun as long as it does not contain a lie.
He warned those people who used to tell lies to make fun of bad consequences. In a Hadeeth the Prophet said: “Woe to him who tells things, speaking falsely, to make people laugh thereby, woe to him! Woe to him!”
Based on this Hadeeth, using lies to make fun is forbidden, so every Muslim should avoid that kind of joking.
We would like to draw your attention to an important point that all joking and fun in religious matters is absolutely forbidden. Imam Ibn al-‘Arabi said: "Making fun in the religious matter is foolishness. Allah Says (what means): {And [recall] when Moses said to his people, "Indeed, Allah commands you to slaughter a cow." They said, "Do you take us in ridicule?" He said, "I seek refuge in Allah from being among the ignorant."} [Quran 2:67]
That means I do not make fun in the matter of religion since this is the practice of foolish people, so you slaughter the cow and you will see the result.
We would like to tell you that making fun should be in the proper way and on appropriate occasions. A Muslim should not engage in it at the time of work and seriousness. Humor should be moderate; i.e., limited to what is appropriate.
Every humor that contains bad words, dissoluteness, or obscenity is disliked and is against the Sunnah.
For more benefit on lying when joking, please refer to Fataawa 394282, 350794, 345604 and 335944.
Allah knows best.