Introduction
It seems that the confusion may arise from the presumption that chapter's primary concern is sexual practices; it is not. It is easy to see how this confusion might arise however. As modern westerners, we lack familiarity with Canaanite/Egyptian pagan religious practices and this understandably leads to the assumption that this passage is concerned with sexual practice. Instead this passage centers on religious practice.
Furthermore, it should be noted that Molech, was a primarily caananite god, not Ammonite. This misunderstanding likely arises from 1 Kings 11:7, from the KJV translation which renders 1 Kings 11:7 as,
for Molech, the abomination of the children of Ammon
yet in 11:33 begins calling this god Milcom. It is clear from the Septuagint that rabbinical tradition instead saw 1 Kings 11:7 as referring to the Ammonite king, not Molech and translates the passage as
τῷ βασιλεῖ αὐτῶν εἰδώλῳ υἱῶν Αμμων ("for their king, idol of the sons of Ammon")
From/Structure
Leviticus 18 begins with the introduction:
The Lord said to Moses, “Speak to the Israelites and say to them: ‘I am the Lord your God. You must not do as they do in Egypt, where you used to live, and you must not do as they do in the land of Canaan, where I am bringing you. Do not follow their practices. You must obey my laws and be careful to follow my decrees. I am the Lord your God. Keep my decrees and laws, for the person who obeys them will live by them. I am the Lord.
The text then goes on to enumerate and condemn the religious practices of the Caananites and Egyptians.
Finally, this passage is book-ended with the conclusion,
“‘Do not defile yourselves in any of these ways, because this is how the nations that I am going to drive out before you became defiled. Even the land was defiled; so I punished it for its sin, and the land vomited out its inhabitants. But you must keep my decrees and my laws. The native-born and the foreigners residing among you must not do any of these detestable things, for all these things were done by the people who lived in the land before you, and the land became defiled. And if you defile the land, it will vomit you out as it vomited out the nations that were before you.
“‘Everyone who does any of these detestable things—such persons must be cut off from their people. Keep my requirements and do not follow any of the detestable customs that were practiced before you came and do not defile yourselves with them. I am the Lord your God.’”
So, in the intervening passages, it is clear that the author is listing and enumerating specific practices that he/God finds detestable.
Historical Background
In Caanan
While this text specifically mentions Molech, it is clear from the sin list in Leviticus 18, that the author is also condeming the worship practices of the followers of Asherah. Ashera was a fertility goddess and followers often worshipped her through sacred prostitution and ritual (and sometimes incestuous) sexual practice.
According to Ray Vander Laan in Prophets and Kings Discovery Guide: Being in the Culture and Not of It
Asherah, in various forms and with varying names (Ashetoreth, for example), was honored as the fertility goddess (judges 3:7). The bible does not actually describe her, but archeologists have discovered figurines believed to be representations of her. She is portrayed as a nude female, somestimes pregnant, with exaggerated breasts that she holds out apparently as symbols of her fertility. The Bible indicates that she was worshiped near trees and poles called, Asherah poles (Deuteronomy 7:5; 12:2-3; 2 Kings 16:4; 17:10; Jeremiah 3:6, 13; Ezekiel 6:13). Although Asherah was believed to be Baal's mother, she was also his mistress, and ritual sex was one way she was worshiped
Following in this fertility theme, Asherah poles were also a phallic symbol of fertility.. In a similar work coauthered with Stephen and Amanda Sorenson, Ray Vander Laan notes
their worshippers engaged in immoral sex to cause the gods to join together and therby ensure good harvests. This practice became the basis for religious prostituion (1 Kings 14:24-24). The priest or a maile communit member represented Baal. The priestess or a female community member represented Asherah. This God's incredible gift of sexuality within the bonds of marriage was perverted and become obscene public prostitution.
It is likely that similar worship practices were seen be followers of other Cannanite gods such as
- Anat, virgin goddess of war and strife, sister and putative mate of Ba'al Hadad
- Baal Hammon, god of fertility
- Dagon (Dagan) god of crop fertility and grain
- Kotharat, goddesses of marriage and pregnancy
- Perhaps many others
In Egypt
The associations to the Caanaite pantheon do not end there. As it turns out, Asherah was a prominent goddess worshiped in Egypt as well under the name Qetesh (or Kadesh) and the Qetesh stele depicts her holding a snake (which has led many scholars to note an association to the snake Moses placed on the pole in Numbers 21:4-9 with the Asherah pole). Thus the condemnation of Egyptian religious practices are directed at the same gods.
Also noteworthy is the association between Qetesh and prostitution and homosexual practices. It seems that the Egyptian name of this goddess shares a root with or gave rise to the Hebrew words for prostitution: קָדֵשׁ (qadesh) which was used to refer to both male and female temple prostitutes and comes from the Semitic root for "sacred" or "Holy".
Conclusion
With the forgoing historical/cultural background, it is much easier to see how these subjects all or mostly relate to Cannanite religious practice. The prohibitions in 6-8, are squarely targeted at the sexual worship practices of the followers of Asherah and Baal. Verse 9 is squarely targeted at the sexual worship practices of the followers of Anat. Verse 22 is targeted at male patrons of the male קָדֵשׁ (qadesh) which is sometimes translated as "sodomites" (such as in some translations of 2 Kings 23:7). It was also common practice for deities to be anthropomorphized as and associated with a particular animal. For example both Baal and Molech were depicted as Bulls or Minotaur, so it is not out of place to think that the prohibitions of Bestiality in 23 are targeting a specific sexual worship practice of the followers of Baal or Molech. Verse 23 prohibiting the sacrifice of Children would be wholly at home amongst these other religious rituals if we view this chapter about the prohibition of religious practices in instead of sexual practices.