The Bible condemns homosexuality not due to the will of God, but as the result of a human attempting to do the right thing.
The prohibition of homosexuality is just one of a long list of rules. The same list defines what is and is not kosher, and forbids shaving the head.
A lot of prohibited activities were part of the surrounding cultures.
I had a long talk with the former host of WXPN’s Gay dreams on the subject of the Talmud and homosexuality. The Jews were in danger of assimilating and losing their identity as a people. Then some elders discover a sacred text with a few hundred commandments. Shlomo is now forbidden to go to the gym with Marcus and Crassus and exercise in the nude. He can go to Marcus’ party, but he’s not allowed to eat the food, drink the wine, or participate in the gay sex.
Banning homosexual activity also helped keep Jews in relationships which would create more Jews.
Eventually, the reason for the ban was lost.
Despite what some Fundies say, Rabbinical opinion has always been that the great sin of Sodom and Gamorah was not homosexuality, but lack of compassion. One legend says that any stranger entering the town would be given a huge sack of gold. But merchants would refuse to sell the stranger any goods, even food and water. Eventually the stranger would die of hunger and thirst. The townsfolk would then take back the gold and wait for the next stranger.