The reason of revelation:
When Abu Sufyan and the polytheists left Uhud and reached Al-Ruha’ place, they said: “You did not kill Muhammad, nor did you bring captured women, the evil of what you did.” When the Prophet (saws) was informed of that, he called the people to pursuit the returning Quraysh army, when they reached Hamra al-Asad or the well of Abu ‘yaynah, this verse was revealed:
There are two issues here: Doing good and (Ihsan) and fearing Allah (swt) (righteousness). Ihsan as defined by the Prophet (saws):
“To worship Allah as if you see Him, and if you cannot achieve this state of devotion then you must consider that He is looking at you.”[1]
And the righteous are defined by the Holy Qur’an by saying:
إِنَّ الْمُتَّقِينَ فِي جَنَّاتٍ وَعُيُونٍ (15) آخِذِينَ مَا آتَاهُمْ رَبُّهُمْ إِنَّهُمْ كَانُوا قَبْلَ ذَلِكَ مُحْسِنِينَ
{Indeed, the righteous will be among gardens and springs. (15) Accepting what their Lord has given them. Indeed, they were before that doers of good.} (Adh-Dhaariyat: 15-16)
This religion is great, and it is a religion of benevolence (Ihsan), as stated in these verses, which bear a response to everyone who accuses Islam of violence and terrorism.
[1] Sahih al-Bukhari: Chapter of Faith, Section: Question of Jibril about Iman, Islam, Ihsan and the the last day, Hadith No. 50.