In the Bible, the word "know" is used as a euphemism for sex.
And Adam knew Eve his wife; and she conceived, and bare Cain (Genesis 4:1)
And Cain knew his wife; and she conceived, and bare Enoch (Genesis 4:17)
This same word is used later when two angels come to the city of Sodom to visit Lot. All the men of Sodom come to Lot's house to "know" the angels.
And they called unto Lot, and said unto him, Where are the men which came in to thee this night? bring them out unto us, that we may know them. (Genesis 19:5)
So does this mean that the men of Sodom wanted to have sex with the angels or could "know" mean something else in this context?
Yahweh said, Shall I hide from Abraham that thing which I do... For I know him. (Genesis 18:17,19)
Whoa! If "know" always means sex, then God just admitted to doing it with Abraham! It turns out the Hebrew word yadha (to know) appears over 900 times in the Old Testament, but it refers to sexual intercourse only ten of those times. If "know" meant sex every time it was used in the Bible, we'd all have to stifle giggles when reading verses such as these:
I know all the fowls of the mountains (Psalm 50:11)
O lord, thou hast searched me, and known me. (Psalm 139:1)
If we follow on to know the LORD: his going forth is prepared as the morning; and he shall come unto us as the rain. (Hosea 6:3)
Yet I am the LORD thy God from the land of Egypt, and thou shalt know no god but me: for there is no saviour beside me. I did know thee in the wilderness, in the land of great drought. (Hosea 13:4-5)
I am the good shepherd, and know my sheep (John 10:14)
My sheep hear my voice, and I know them (John 10:27)
As the Father knoweth me, even so know I the Father (John 10:15)
Wherefore henceforth know we no man after the flesh: yea, though we have known Christ after the flesh, yet now henceforth know we him no more. (2 Corinthians 5:16)
And we beseech you, brethren, to know them which labour among you (1 Thessalonians 5:12)
And Joseph saw his brethren, and he knew them (Genesis 42:7)
And as Obadiah was in the way, behold, Elijah met him: and he knew him (1 Kings 18:7)
The ox knoweth his owner (Isaiah 1:3)
No man knoweth the Son, but the Father; neither knoweth any man the Father, save the Son (Matthew 11:27)
OK, so if "know" doesn't automatically mean sex, what else could it mean in the context of the Sodom story? Why did the men of Sodom want to "know" the angels who were spending the night with Lot? The men of Sodom were suspicious of the angels because they were strangers. They wanted to know who they were and what business they had in the city. They wanted to size them up and see if they were going to be trouble makers. Lot was afraid they were going to beat his guests up, for he says:
I pray you, brethren, do not so wickedly. Behold now, I have two daughters which have not known man; let me, I pray you, bring them out unto you, and do ye to them as is good in your eyes: only unto these men do nothing; for therefore came they under the shadow of my roof. (Genesis 19:6-8)
If the men of Sodom were homosexual, why would Lot tell them to rape his virgin daughters? Homosexual men generally aren't interesting in having sex with women.
And they said, Stand back. And they said again, This one fellow came in to sojourn, and he will needs be a judge: now will we deal worse with thee, than with them. And they pressed sore upon the man, even Lot, and came near to break the door. (Genesis 19:9)
Lot himself is a sojourner in Sodom. He is not a full citizen, but rather a (gasp!) immigrant. The men of Sodom don't look too kindly on immigrants. Lot's refusal to release the angels to their custody makes him as guilty as they are. Fortunately the angels use their special illegal immigrant powers:
But the men put forth their hand, and pulled Lot into the house to them, and shut to the door. And they smote the men that were at the door of the house with blindness, both small and great: so that they wearied themselves to find the door. (Genesis 19:10-11)
The Bible itself never suggests that the sin of Sodom was homosexuality. There's a strikingly similar story in Judges 19 where a man spends the night with a sojourner in Gibeah:
Behold, the men of the city, certain sons of Belial, beset the house round about, and beat at the door, and spake to the master of the house, the old man, saying, Bring forth the man that came into thine house, that we may know him. And the man, the master of the house, went out unto them, and said unto them, Nay, my brethren, nay, I pray you, do not so wickedly; seeing that this man is come into mine house, do not this folly. Behold, here is my daughter a maiden, and his concubine; them I will bring out now, and humble ye them, and do with them what seemeth good unto you: but unto this man do not so vile a thing. (Judges 19:22-24)
This version of the story has a more gruesome ending:
But the men would not hearken to him: so the man took his concubine, and brought her forth unto them; and they knew her, and abused her all the night until the morning: and when the day began to spring, they let her go. Then came the woman in the dawning of the day, and fell down at the door of the man's house where her lord was, till it was light. And her lord rose up in the morning, and opened the doors of the house, and went out to go his way: and, behold, the woman his concubine was fallen down at the door of the house, and her hands were upon the threshold. And he said unto her, Up, and let us be going. But none answered. Then the man took her up upon an ass, and the man rose up, and gat him unto his place. And when he was come into his house, he took a knife, and laid hold on his concubine, and divided her, together with her bones, into twelve pieces, and sent her into all the coasts of Israel. (Judges 19:25-29)
Unlike the version in Genesis, this earlier version of the story explains what the men of the town intended to do:
I came into Gibeah that belongeth to Benjamin, I and my concubine, to lodge. And the men of Gibeah rose against me, and beset the house round about upon me by night, and thought to have slain me: and my concubine have they forced, that she is dead. (Judges 20:4-5)
According to the Bible, when the men of Gibeah asked to "know" the stranger, that meant they wanted to kill him, not have sex with him. If this is what "know" means in the Judges version of the story, then that's probably what it means in the Genesis version of the story as well. The sin of Sodom is not described as being homosexuality elsewhere in the Bible either:
I have seen also in the prophets of Jerusalem an horrible thing: they commit adultery, and walk in lies: they strengthen also the hands of evildoers, that none doth return from his wickedness; they are all of them unto me as Sodom, and the inhabitants thereof as Gomorrah. (Jeremiah 23:14)
Behold, this was the iniquity of thy sister Sodom, pride, fulness of bread, and abundance of idleness was in her and in her daughters, neither did she strengthen the hand of the poor and needy. And they were haughty, and committed abomination before me: therefore I took them away as I saw good. (Ezekiel 16:49-50)
Whereas the men of Sodom received not the strangers when they came among them, so the Egyptians made slaves of the guests who were their benefactors. (Wisdom 19:13-14, Ecclesiastes 16:8).
Now whatever city or town you enter, inquire who in it is worthy, and stay there till you go out. and when you go into a household, greet it. If the household is worthy, let your peace come upon it. But if it is not worthy, let your peace return to you. And whoever will not receive you nor hear your words, when you depart from that house or city, shake off the dust from your feet. Assuredly, I say to you, it will be more tolerable for the land of Sodom and Gomorrah in that day of judgement than for that city! (Matthew 10:11-14, Luke 10:8-12)
So according to the Bible, the sin of Sodom wasn't homosexuality, but rather inhospitality. Thus the word sodomy, just like onanism, came about due to a misreading of the text. Technically, the definition of the word "sodomy" should be "being hostile to foreigners." The Bible does indeed condemn homosexuality elsewhere (Leviticus 20:13, Romans 1:26-28), but not in connection with Sodom.