Abridged: It is obligatory to return the Islamic greeting
Imaam Ibn Abdul-Barr (rahimahullaah) said: The obligation of returning the Islamic greeting is (found in the) statement of (Allaah):
وَإِذَا حُيِّيتُم بِتَحِيَّةٍ فَحَيُّوا بِأَحْسَنَ مِنْهَا أَوْ رُدُّوهَا
”When you are greeted with a greeting, greet in return with what is better than it, or (at least) return it equally.”
[Nisaa: ayah: 86]
Imaam Ibn Katheer (rahimahullaah) said:
To give the Islamic greeting is voluntary and it is an obligation to return it. This is what the scholars say collectively, that it is an obligation upon the one who is given the salaam to reply to it; and he has sinned if he does not reply to it, because he has opposed the command of Allaah (The Most high).
The abandonment of returning the Islamic greeting is an evil and ugly deed and many people have been afflicted with it in this era. And they are prevented from it due to pride and self-amazement. So we gently say to all of them, ”Who are you?! And from what are you from?!” Allaah said:
”From what thing did He create him? From Nutfah (male and female semen drops) He created him, and then set him in due proportion”
[Abasa: Ayah: 17…]
Are you greater in status than the Messenger (sallal-laahu-alayhi-wasallam)? Indeed he (sallal-laahu-alayhi-wasallam) returned the Islamic greeting of the young, the old, the free person and the slave, and he also greeted them. Therefore, let there be a good example in the Messenger of Allaah for you to follow. We ask Allaah for guidance and success for all.
Also when a person is leaving a gathering and gives the salaam, it is obligatory to reply to him.
[For further details, see: Al-Ilaam Bi-Ba’di Ahkaam As-Salaam of Shaikh Abdus-Salaam Burgess (rahimahullaah) page: 11-12]