The meaning of the verse
"Al-'adl" (justice): giving everyone their due; Allah's right is that no one is made a partner with Him in worship, and people's right is fairness in judgements, testimony, dealings and treatment of one's family. "Al-ihsan" (excellence): going beyond justice to do good, giving more than is due and performing worship in the best way. In the hadith of Jibril in Sahih al-Bukhari and Sahih Muslim, the Prophet ﷺ defined ihsan as worshipping Allah as though you see Him. "Ita'i dhil-qurba" (giving to relatives): giving relatives their right through wealth, time and good treatment.
Then the verse forbids three things: "al-fahsha'", meaning indecency and great shameful sins; "al-munkar", meaning every deed that the Shariah and sound human nature regard as evil; and "al-baghy", meaning oppression, transgression and violating people's lives, wealth and honour. At the end Allah says: "He admonishes you, that you may take heed." That is, these commands are sincere good counsel from the Lord.
The most comprehensive verse of the Quran
Abdullah ibn Mas'ud used to say that regarding the lawful and the unlawful, and commands and prohibitions, there is no verse in the Quran more comprehensive than this one. This is reported in Al-Adab al-Mufrad and Mustadrak al-Hakim with a reliable chain, through the testimony of his students Masruq and Shatir bin Shakl (may Allah have mercy on them). The well-known Tabi'i (Successor) Hasan al-Basri (may Allah have mercy on him) recited this verse and said that Allah has gathered all good and all evil for you in a single verse; justice and ihsan left out no part of obedience, and indecency and wrongdoing left out no part of disobedience.
This verse in the Friday khutbah
Today many khatibs (preachers) recite this verse at the end of the second Friday khutbah. History books report that this custom was adopted by the caliph Umar ibn Abd al-Aziz (may Allah have mercy on him). The verse is a very fitting admonition for a khutbah and there is no harm in reciting it, but it is not an established Sunnah of the Prophet ﷺ, so it is not correct to treat it as a required part of the khutbah or to consider a khutbah without it deficient. What is established in the Prophet's ﷺ khutbahs is praise of Allah, recitation of the Quran and admonition, and sticking to any one particular verse is not established.
Famous narrations about the reason for revelation
Two incidents are well known about this verse. The first is that Uthman ibn Maz'un (may Allah be pleased with him) was sitting with the Prophet ﷺ when this verse was revealed to him, and at that moment faith became firm in his heart. This narration is in Musnad Ahmad and Al-Adab al-Mufrad, and the hadith scholars differ about its chain: Hafiz al-Haythami (may Allah have mercy on him) called it hasan, while Shaykh al-Albani (may Allah have mercy on him) graded it weak.
The second is reported from Uthman ibn Abi al-As (may Allah be pleased with him): that Jibril (peace be upon him) commanded that this verse be placed at this position in the surah; its chain is weak because of Layth ibn Abi Sulaym and Shahr ibn Hawshab. So these narrations cannot be relied on with certainty, but the message of the verse does not depend on them.