The Prophet (Peace and Blessings of Allah be upon him) said, “Allah likes sneezing and dislikes yawning. When any one of you sneezes and says ‘Al-Hamdu Lillah (Praise be to Allah)’. It becomes obligatory upon every Muslim who hears him to respond with ‘Yarhamuk-Allah (May Allah have mercy on you)’. Yawning is from the devil. When one of you feels like yawning, he should restrain it as much as possible, for the devil laughs when one of you yawns.
It was reported from Abu Hurayrah (May Allah be pleased with him) that the Prophet Muhammad (Peace and Blessings of Allah be upon him) said: “If any one of you sneezes, let him say, ‘Alhumdulillah’, and let his brother or his companion say, ‘Yarhamuk-Allah’. And if he says to him, ‘Yarhamuk-Allah’, let him say, ‘Yahdeekum Allahu wa yusliha baalakum (May Allah guide you and correct your thinking.’” – Reported by Al-Bukhari 10/502
Sneezing brings a person the blessing of relief by releasing vapours that were trapped in the head which, if they were to remain there, would cause him pain and sickness. For this reason, Islam tells him to praise Allah for this blessing and for the fact that his body is still intact after this jolt that shook him like an earthquack; for sneezing causes a disturbing movement in the body.
When a person mentions Allah and praises Him, this annoys the Shaytan in several ways, for example: the act of sneezing itself which Allah likes, his praising Allah for it, the Muslims praying for mercy for him, and his prayer for them to be guided. All of this annoys the Shaytan and makes him upset, so the believer is told to rejoice over his annoyance of his enemy.
Ibn Hubayrah said, “If a person sneezes, this is an indication of good health, sound digestion and physical strength, so he should praise Allah. This is why the Messenger of Allah (Peace and Blessings of Allah be upon him) commanded us to praise Allah.”
It is also important to know that the Muslim should submit to the texts and act in accordance with them without trying too hard to understand precisely why a text commands or forbids something. He should believe that Allah, the Most High and Exalted, is the Wise and Aware; Who does not prescribe anything for His slaves unless it is in their best interests, in this world and in the next, although it may cross their minds and some people may understand a part of the wisdom behind it whilst others will never know. The Muslim’s basic rule is to follow the commands. To follow what the Prophet Muhammad (Peace and Blessings of Allah be upon him) ordered us to do because if you don’t follow the Sunnah, you’re not really following the right path.
And Allah, The Magnificent knows best.