Lūṭ warned his people against indecency and called them to obey Allah. Allah rescued him and the believers when his people persisted in rejection.
The story
A warning against indecency
Lūṭ called his people to fear Allah and obey the messenger sent to them. He sought no payment for his teaching. He condemned their indecency, including men turning to men instead of the marriage Allah had provided. Rather than accept correction, the people threatened to drive him out. He rejected their conduct and asked Allah to rescue him and his family.
Angels came to Lūṭ as guests, and he was distressed because he feared how his people would behave toward them. A crowd approached with wrongful intentions. He urged them to fear Allah and not disgrace him through his guests. The visitors then revealed that they were messengers from Allah and assured him that the people would not be able to reach him.
The angels instructed Lūṭ to leave with his family during the night. His wife was excluded from the rescue and would share the punishment of the people. At the appointed time, Allah overturned their towns and sent down stones upon them. The account preserves their destruction as a warning, while showing Allah's rescue of His messenger and those who followed him.
The people answered a warning about wrongdoing with threats against the person delivering it. Their agreement with one another did not make their conduct right. Lūṭ remained clear about the wrong while asking Allah for rescue rather than accepting the crowd's judgment.
The wife of Lūṭ was not included among those saved. The account warns that living near a prophet is not the same as following his guidance. Each person needs a sincere response to Allah rather than relying on family connection for protection.
Summaries of Ibn Kathīr's commentary on the linked āyāt, with authentic ḥadīth noted in the text where used. Verse links open Quran.com text and your chosen translation.