What is the ruling of answering salam?
Alhamdulillah, praise and gratitude to Allah SWT for His countless blessings for us all. Praise and salutations to our beloved Prophet Muhammad PBUH, his family, companions, and all those who follow his footsteps until the Final day.
Salam is a peace and harmony greeting with the purpose of honouring and acknowledging our Muslim brothers. Giving and answering salam is a sunnah that is encouraged in religion. Allah SWT stated in the Quran:
وَإِذَا حُيِّيتُم بِتَحِيَّةٍ فَحَيُّوا بِأَحْسَنَ مِنْهَا أَوْ رُدُّوهَا
“And when you are greeted with a greeting, greet [in return] with one better than it or [at least] return it [in a like manner].” 
Ibn al-Arabi stated in Ahkam al-Quran : When answering salam, it is obligatory without any khilaf. Maliki scholars used this verse as evidence in ruling it obligatory for a reply or return in a matter of hibah al-thawab (a good gift) which means a gift that needs a return gift or reward. For example, in an honouring speech, a person honoured is obligated to return the honour, the same for hibah al-thawab, it is obligatory for an equal return.
He cited the words of Imam al-Syafie: We don’t do any deed for Allah except hoping for Allah SWT’s rewards for us. Especially if is a gift between ourselves.
The Prophet PBUH once said to Aisyah R.Anha:
يَا عَائِشَةُ هَذَا جِبْرِيلُ يَقْرَأُ عَلَيْكِ السَّلاَمَ، فَقُلْتُ : وَعَلَيْهِ السَّلاَمُ وَرَحْمَةُ اللَّهِ. وَهُوَ يَرَى مَا لاَ أَرَى
‘A’isha, here is Gabriel offering you greetings. She said: I made a reply: Let there be peace and blessings of Allah upon him, and added: He sees what I do not see.” 
Imam al-Nawawi when commenting on this hadith stated: “Whoever receives a salam (from another person), he should answer it. Answering it is an immediate obligation (on him).” 
Imam al-Nawawi further added: Know that giving salam is sunnah and answering it is obligatory. If a Muslim is in a part of a group, then it is fardhu kifayah on them and if just some of them utter the salam all of them receive the sunnah of the salam. When a person is alone, then it is fardhu ain for him to answer the salam. If he is in a congregation, then answering the salam is fardhu kifayah on them and if just one of them answers it, then the sin is abrogated for all the others. However, it is prioritized for all of them to give and answer salam. 
To close, we’d like to remind you that it is sunnah for everyone to give salam according to the appropriate situation taught by the Prophet PBUH. However, answering salam is obligatory as we’ve stated previously. We end this discussion with the words of Imam al-Nawawi:
“Know that giving salam is sunnah and commendable however, it is not an obligation. It is also sunnah kifayah, which means that when a Muslim in a congregation (group) has given it, this is enough. If all of them utter salam, then this is better. As for answering salam, if one is greeted with salam, he must answer it and if it is a greeting for a group of people then it is fardhu kifayah for them to answer it. When one of them answers the salam then it is sufficient for others and all of them are freed from the sin. However, if all of them answer the salam, then this is the best and perfect response.” 
Lastly, may Allah SWT grant us the strength in practising the sunnah of the Prophet PBUH and protect us from attributes that are disliked by Allah SWT and His Messenger PBUH. Amin.