Someone preached it was for inhospitality.
Wanting to bugger strangers coming to town sure is inhospitable.
Still, you can always reply that their homosexuality was the outward manifestation of their already depraved minds, in keeping with the principal much later expounded in Romans 1.
Remember what the Lord said to Abraham:
“Shall I hide from Abraham what I am about to do? Abraham will surely become a great and powerful nation, and all nations on earth will be blessed through him. For I have chosen him, so that he will direct his children and his household after him to keep the way of the Lord by doing what is right and just, so that the Lord will bring about for Abraham what he has promised him.”
“The outcry against Sodom and Gomorrah is so great and their sin so grievous that I will go down and see if what they have done is as bad as the outcry that has reached me. If not, I will know.”
I would suggest that the first part makes the reason for the angel’s mission to be so that Abraham would know too that their sin was so grave, because it had been investigated. So when people later acted like the fate of the cities of the plain was not justified, that Abraham would know the truth.