Sayyiduna Imran bin Husain (may Allah be pleased with him) said: A companion came to the Prophet (peace and blessings be upon him) and said: "As-salamu Alaikum." The Prophet (peace be upon him) replied and said: "Ten." Then another companion came and greeted in this way: "As-salamu Alaikum wa Rahmatullah." The Prophet (peace be upon him) replied to him as well and said: "Twenty." Then another companion came, greeted, and said: "As-salamu Alaikum wa Rahmatullahi wa Barakatuh." The Prophet (peace be upon him) replied and said: "Thirty" (meaning for these three words, there are thirty good deeds for him).
Hadith Referenceسنن دارمي / من كتاب الاستئذان / 2676
Hadith Takhrijاس حدیث کی سند صحیح ہے۔ دیکھئے: [أبوداؤد 5195] ، [ترمذي 2690] ، [طبراني 134/18، 280، ويشهد له ما فى صحيح ابن حبان 493]
Brief Explanation
(Commentary on Hadith 2675)
From this hadith, it is understood that saying only "as-salamu alaykum" earns ten good deeds; adding "wa rahmatullahi" earns twenty good deeds; and adding "wa barakatuh" earns thirty good deeds. Similarly, the one who replies also receives good deeds.
Allah Ta'ala says: «﴿وَإِذَاحُيِّيْتُمْبِتَحِيَّةٍفَحَيُّوْابِأَحْسَنَمِنْهَاأَوْرُدُّوهَا .....﴾ [النساء : 86]» Translation: "When you are greeted with a greeting, then respond with one better than it, or at least return it with the like of it..."