The men who visited Lot were not humans but angels. The people of Sodom were wicked. They were not just homosexuals but evil men who didn't bear in mind to be hospitable to travelers who passed their land.
Also they did not respect Lot who lived among them. They threatened Lot as well when he intervened and tried to protect the angels.
It was God's plan. That the men of Sodom should act out wickedly before a final punishment can be dealt to them. Lot did ask his to be sons in law to go with him and his family but they though he was joking and stayed behind and were destroyed.
This is not modern society we're discussing. Such barbaric acts were done in those times.
Why go so far back?
What happened in the age of colonialism when European countries started to colonize all continents? So much rape and murder.
What happened during the World Wars? It is human nature.
God punished Sodom accordingly and saved those who believed in Him. He didn't allow those faithful to him to perish along with the others in the sulfur just as God promised Abraham.
Those people acted wickedly because God wanted them to so that He could humble the people of Sodom. The same way God did to Pharaoh when he refused to let the Israelites leave Egypt. God hardened Pharaoh's heart and then humbled him and the Egyptians and brought out His people who believed in Him.
It was already God's plan to destroy Sodom and Gomorrah. To do this, those wicked people had to make the final act of sin so that God could execute Judgement upon them.
You have to read the entire account of how Lot was brought out of Sodom right from God visiting Abraham and Sarah through the same angels who would then visit Lot's family. Then you would understand better.
The primary sin of Sodom was "going after STRANGE FLESH", specifically ANGELIC flesh. Evidently in a manner similar to what was going on before the flood (unlawful sinful contact between angelic beings and men).
Such contact has inevitably led to extremely catastrophic judgements of the cosmic kind. Not merely the political dissolution of a sinful kingdom.
Peter CLEARLY links Genesis 6 with the sin and subsequent destruction of Sodom. Unmistakably.
Jde 1:7
Even as Sodom and Gomorrha, and the cities about them in like manner, giving themselves over to fornication, and
going after strange flesh, are set forth for an example, suffering the vengeance of eternal fire.
2Pe 2:4
For if God spared not the
angels that sinned, but cast
them down to hell, and delivered
them into chains of darkness, to be reserved unto judgment;
2Pe 2:5
And spared not the old world, but saved Noah the eighth
person, a preacher of righteousness, bringing in the flood upon the world of
the ungodly;
2Pe 2:6
And turning the cities of Sodom and Gomorrha into ashes condemned
them with an overthrow, making
them an ensample unto those that after should
live ungodly;