Name and why it is called so
The surah takes its name from its first verse, "Wash-shamsi wa duhaha" (By the sun and its brightness). In the hadith it is mostly referred to by the words "Wash-shamsi wa duhaha." Surah Ash-Shams contains a long chain of oaths that begins with the signs of the universe and ends with the human soul, and all of them have one answer: purification of the soul is success.
Time of revelation and background
This surah was revealed in Mecca when the rebellion of the Quraysh was growing, so they were given the example of the people of Thamud, who hamstrung the she-camel of Allah. Sahih al-Bukhari narrates from Abdullah ibn Zam'ah (may Allah be pleased with him) that the Prophet ﷺ, explaining "idhinba'atha ashqaha" (when the most wretched of them rose up) in a sermon, said that a wretched man, powerful and dominant among his people like Abu Zam'ah, rose up to kill the she-camel.
Main themes
In the first ten verses Allah swears by the sun, by the moon that follows it, by the bright day, by the night that covers, by the sky and the One who built it, by the earth and the One who spread it, and by the soul and the One who proportioned it and inspired it with its wickedness and its righteousness. The answer to these oaths is: indeed he succeeds who purifies his soul, and indeed he fails who buries it.
The last part tells the story of the people of Thamud, who in their rebellion denied Prophet Salih, peace be upon him. When the most wretched of them rose up, and despite the warning of Allah's Messenger they killed the she-camel, their Lord destroyed them for their sin and leveled them all, and He does not fear its consequences. This is the essence of the tafsir of Surah Ash-Shams.