Is Being Gay a Sin?

Regarding your example about the Israelites and the children of their enemies: the nations they encountered were engaged in practices that were abhorrent to God, including homosexuality, child sacrifice, and other detestable sins (see Lev 18:24–25, Deut 12:31). These nations knew the natural law written on their hearts (Rom 2:14–15)—they knew murder and idolatry were wrong—yet they persisted in rebellion.

God’s judgments were not arbitrary; they were a response to persistent, unrepentant sin. Even if one had repented, God’s mercy would have prevailed (cf. Jonah and Nineveh). The point is that God’s commands regarding morality—including prohibitions on homosexual acts—are rooted in His justice and the moral order, not merely cultural preference or arbitrary law.
I have talked about this in: