I'm so glad you asked! Since this is the part of the Bible that deals with Jewish legend and history, I'll quote the Jewish Rabbi Hillel (who lived in the century before Jesus and may have overlapped with him a little): ‘That Which Is Hateful to You, Do Not Do to Your Fellow! That is the Whole Torah; The Rest is Interpretation’ (from the Elder Hillel in Babylonian Talmud, Shabbat 31a).
The Torah is full of stories of divine punishments, plagues, et cetera. It's very dramatic, and should be read with spiritual guidance and reflection, as with all old and powerful stories. As for what the cities of Sodom and Gomorrah were being punished for, perhaps it was the attempted rape of the angelic visitors? Rape is cruel, and a sin, I hope we can all agree. But if you want to pin it on rule-following behavior as opposed to actual cruelty, then the answer could be that God punished them for eating shellfish (definitely a sin by OT standards). Doesn't that make you pause before you try to impose sexual mores from that culture on your own? If you start interpreting the Word of God as a license to hate or punish, you are wandering far away from the spirit.
Reading with the light of charity: We are reminded multiple times that WE are not in charge of judging or punishing sin: "Dearly beloved, avenge not yourselves, but rather give place unto wrath: for it is written, Vengeance is mine; I will repay, saith the Lord." (Romans 12:19); "He who is without sin among you, let him throw a stone at her first." John 8:7; and, tellingly, the Parables of the Vinyard Workers (Matthew 20: 1–16), where we are reminded that people we may not think are saved are nonetheless worthy of reward in God's eyes, and of the Prodigal son (Luke 15:11-32).
Finally, Matthew 7:3 reminds us all that we should worry about these rules and prohibitions for OURSELVES, not for other people.