And the one hearing it must say, “Yarahmukallah”. It is said to rejoice over the misfortune of Shaytaan i.e.., when a mumeen (Believer) says Alhamdhulillah after sneezing, it would annoy Shaytaan, and that’s why the listener must say “Yarahmukallah”.
Narrated Abu Huraira (Radhiallahu’Anhu): ”The Prophet Muhammad (Salallahu’Alayhiwassalam) said, ” If anyone of you sneezes, he should say ‘Al-Hamduli l-lah’ (Praise be to Allah), and his (Muslim) brother or companion should say to him, ‘Yar-hamuka-l-lah’ (May Allah bestow his Mercy on you). When the latter says ‘Yar-hamuka-llah”, the former should say, ‘Yahdikumul-lah wa Yuslih balakum’ (May Allah give you guidance and improve your condition).“ [Sahih Bukhari, Book 73, Vol 8, Hadith # 243]
And moreover it’s a Sunnah of the Prophet Muhammad (Salallahu’Alayhiwassalam). Allah likes sneezing, because it makes his servants to praise him “Alhamdhulillah”. Hence, this is why we say Alhamdhulillah after sneezing.
When someone does not praise Allah, do not wish mercy on him
Abu Hurayra said, "Two men sat in the presence of the Prophet may Allah bless him and grant him peace, and one of them was from a noble family than the other. The nobler of the two sneezed and did not praise Allah, so the Prophet did not ask for mercy for him. Then the other man sneezed and praised Allah, so the Prophet, may Allah bless him and grant him peace, asked for mercy on him. The noble man said, 'I sneezed in your presence and you did not ask for mercy for me. This other than sneezed and you asked for mercy on him.' The Prophet said, 'This man mentioned Allah, so I mentioned him. You forgot Allah, so I forgot you.'"