Allah tells us about His servant and Messenger Lut, peace be upon him, and how he warned his people of Allah's punishment for committing an act of immorality which no human ever committed before them -- intercourse with males instead of females. This is a major sin, whereby men are satisfied with men and women are with women (i.e., homosexuality). Lut said:
أَتَأْتُونَ الْفَـحِشَةَ وَأَنتُمْ تُبْصِرُونَ
(Do you commit immoral sins while you see) meaning, `while you see one another, and you practice every kind of evil in your meetings.'
We shall attack him (Salih علیہ السلام) and his family at night, then will say to his heir, We did not witness the destruction of his family and we are really truthful - 27:49.
The plan was that all of them together should attack him and his companions in the darkness of night, and kill them all. And when the claimant of the blood would make the claim, they would say that they did not kill him, and also they did not know who had killed him. In saying so they would have uttered the truth because no one could have known who had killed whom in the darkness of the night.
There were nine great chiefs in this community. In order to maintain their high position they made constant efforts to belittle the Truth, and efforts of this type undoubtedly constitute the greatest disturbance on God’s earth. Finally, these chiefs conspired to kill Salih. But, before they could take any steps against Salih according to their secret plan, God seized hold of them. In spite of all their might they were destroyed so utterly that, only dilapidated ruins of their ancient towns, still stand there as a memorial to them. A great lesson is hidden in such historical events. But, this lesson may be learnt only by one who is capable of connecting such events with the eternal laws of God. Conversely, those who attribute such events to physical causes cannot learn any lesson from them.
Uthmani text of the Madinah mushaf (King Fahd Complex). Translation: Saheeh International. Tafsir via Quran.com.