When Allah created Adam, He ordered him to go to a group of angels and greet them with peace and then listen to their response to his greeting because that would be the prescribed greeting for him and his offspring after him who follow the religion of the messengers. So he said: As-Salāmu ‘alaykum (peace be upon you), and they replied: As-Salāmu ‘alayk wa rahmatullāh (peace and mercy of Allah be upon you), adding 'rahmatullāh' (mercy of Allah). This has, thus, become the prescribed wording when greeting and returning the greeting. Other Hadīths had the addition: "wa rahmatullāh wa barakātuh (...and mercy of Allah and His blessings be upon you!)"
بهجة الناظرين شرح رياض الصالحين، للهلالي، نشر: دار ابن الجوزي. صحيح البخاري، نشر: دار طوق النجاة (مصورة عن السلطانية بإضافة ترقيم محمد فؤاد عبد الباقي)، الطبعة: الأولى، 1422ه. منار القاري شرح مختصر صحيح البخاري، لحمزة محمد قاسم، عني بتصحيحه ونشره: بشير محمد عيون، الناشر: مكتبة دار البيان، دمشق - الجمهورية العربية السورية، مكتبة المؤيد، الطائف - المملكة العربية السعودية، عام النشر: 1410 هـ - 1990 م.