There is quite a lot of dodgy sex stuff in Genesis 19-20, all against the background of the difficult story of Isaac's conception and birth, sidetracked as it got with Hagar's concubinage and the fathering of Ishmael.
In Genesis 19 a rapacious sexuality* asserts itself (19:1-29), then incest creeps in (almost literally on a drunken Lot, 19:30-38). Sarah herself, despite advancing years, is attractive to Abimelech, king of Gerar, who acts on the attraction, takes her, then hands her back on discovery through a dream that she is not Abraham's sister but his wife (20:1-18).
What is going on here? A setting out of ethics via narrative? At the least the narratives illustrate some of the proscribed behaviours in Leviticus 18 - as does the story of Abraham nearly but not sacrificing his child Isaac (Genesis 22; cf. Leviticus 18:21). A settling of ancient scores? This is particularly noticeable in the stories of Abraham, Hagar and Ishmael and Lot, his daughters and their (grand)sons, Moab and Ben-ammi. The emergent nations from these children are of dubious parentage, forever slurred within the history Israel tells itself.
The material we are working with in Genesis 19:1-29 is enigmatic, ambiguous, and contributory to inter-textual echoes throughout the Bible. Some kind of spiritual warfare is going on: angels manifesting as humans become the occasion for rapacious, violent, inhospitable behaviour. The men of Sodom wish to dominate and desecrate them - a vicious manifestation of prior wickedness within the city. But these are not ordinary humans they try to intimidate. As angels they have extraordinary power. They rescue Lot from the vindictive bullying of the assailants, blind the bullies, and destroy the city. Fiery, sulphuric desolation is the fate of Sodom, and of nearby Gomorrah.
The story is 'classic' spiritual warfare: good versus evil; evil appears to have victory in its grasp; but good triumphs and evil is vanquished.
The reactive destruction of Sodom and Gomorrah is of a piece with the story of Noah: wickedness increases on the earth, but it will be checked, and then defeated. If my beginning observation was about dodgy sexuality being narrated through Genesis 19 and 20, a closing observation could be that dodgy humanity is being narrated through these chapters. People can be incredibly righteous (Abraham, many references in Genesis), very caring (Abraham as intercessor for Sodom in Genesis 18:22-33), full of integrity (Abimelech in Genesis 20), and quite stupid (Lot's wife and Lot's sons-in-law, Genesis 19:14,26). But people can also behave badly, so very badly that destruction is the consequence (Genesis 19:1-29).
Why Israel would tell such stories is not hard to fathom. Israel's calling is to be righteous, caring, and to act with integrity. This elect nation should be very clear that wickedness is intolerable to God. But it can be encouraged to trust God who is merciful - to people such as Lot who is not very wise, but has not completely given way to wickedness, to Abimelech who makes an innocent mistake, to Hagar and Ishmael who have been entangled in a complicated moral situation not of their own making - and patient but slow spiritual learners such as Abraham and Sarah. In certain moments Israel is a Lot, an Abimelech, a Hagar and an Ishmael. But mostly Israel is Abraham and Sarah. Called by God. Promised through a covenant to receive a great future. But impatient, unseeing, lacking faith, fearful, while also understanding something of the mercy and love which God asks of them.
With respect to modern concern about homosexuality, Genesis 19 tells us very little. We can only understand ethical imperatives which the narrative touches on (to do with homosexuality, incest) through other texts (such as Leviticus 18). The narrative itself is more interested in other lessons such as avoiding complete moral degradation, and seeking righteous and wise ways of living.
Yet the narrative challenges us in one way in respect of our times. When so much of our discussion is on what we think Scripture means, whether the church might bless or approve such and such a relationship, or not, these chapters in Genesis confront us with the God who sees exactly what we do, who acts mercifully and punitively, though never capriciously. [ADDED NOTE: the view taken here is that Sodom was punished because of its general wickedness, to which the reader begins to be alerted in 18:16-33].
If we seek from Genesis 19 an answer to an ethical question we find no answer which can be isolated from other relevant texts, but we meet the One to whom we all answer for the way we live.
*My initial post had 'homosexuality' here instead of 'sexuality'. I have been thinking further because I acknowledge that 'homosexuality' is a much debated word in this kind of context. Some, for example, advancing the thought that this nineteenth century coined word should only be used to refer to 'modern homosexuality', and perhaps specifically to 'same sex attraction' as opposed to 'same sex sexual activity' which might not involve 'same sex attraction' as understood via modern psychologists. Thus, on this line of understanding, men seeking to dominate other men via sex are not necessarily homosexual, neither are Hellenistic older males and their younger boy friends, all destined later to take up a happy married life. The weakness with this distinction between modern and ancient worlds is that if homosexuality is a phenomenon occurring in nature, including within human experience, then it is not a suddenly appearing feature, but a recurring feature. Ipso facto, it was a part of ancient Middle Eastern life as well as of (say) modern Californian life. I conclude therefore that homosexuality may be properly used in connection with things to do with 'same sex' in ancient times as well as modern. Whether it ought not to be used about men acting out sexually with men for motivations other than attraction is an interesting question. I cannot see a difficulty in taking a word such as homosexuality to speak generally of same sex matters: attraction, as well as activity, whatever the motivation(s) of the latter. There would then need to be clarification through appropriate adjectives and phrasing.
In the case of Sodom it is possible that the rapacious men were motivated by a need to dominate and not by attraction. But I do not see enough detail in the story to rule out attraction playing a role. Not least, of course, because the offer of Lot's daughters was specifically turned down. Either way, what is narrated at Sodom is a vicious and violent expression of sexuality. It would be a long bow being drawn that used this story to condemn all expressions of homosexuality. And that bow is not being drawn here. Nevertheless I shall refrain from using 'homosexuality' here and use a more neutral-for-this-context 'sexuality'.