It has often been said that God brought the Israelites out of Egypt but it took much longer to get Egypt out of the Israelites.
There were essentially three things that made the worship of false god's so detestable in YHWH's sight:
- it involved the worship of either something that did not exist or gave allegiance to satanic forces
- it involved human sacrifice, especially child sacrifice, eg, the worship of Molech and Chemosh
- it involved extreme sensual immorality, eg, the worship of Asherah and the incident of the golden calf in the desert.
This history of Israel in much of the OT is a battle to keep Israel from falling back into these disgusting practices. The same thing occurred when the remnant were later taken out of Babylon (eg, the book of Nehemiah). So much so, it became proverbial and directly referenced in the book of Revelation 18:1-8.
There are numerous references/allusion to human sacrifice in the OT such as:
- 2 Kings 16:3 - Instead, he walked in the ways of the kings of Israel and even sacrificed his son in the fire, according to the abominations of the nations that the LORD had driven out before the Israelites. [I presume the king would not have done this alone.]
- 1 Chron 28:3 - Moreover, Ahaz burned incense in the Valley of Hinnom and sacrificed his sons in the fire, according to the abominations of the nations that the LORD had driven out before the Israelites.
- 2 Kings 21:6 - He sacrificed his own son in the fire, practiced sorcery and divination, and consulted mediums and spiritists. He did great evil in the sight of the LORD, provoking Him to anger.
- 2 Chron 33:6 - He sacrificed his sons in the fire in the Valley of Hinnom. He practiced sorcery, divination, and witchcraft, and consulted mediums and spiritists. He did great evil in the sight of the LORD, provoking Him to anger.
- 2 Kings 17:17 - They sacrificed their sons and daughters in the fire and practiced divination and soothsaying. They devoted themselves to doing evil in the sight of the LORD, provoking Him to anger.
- 2 Kings 23:10 - He also desecrated Topheth in the Valley of Ben-hinnom so that no one could sacrifice his son or daughter in the fire to Molech.
- Eze 16:21 - You slaughtered My children and delivered them up through the fire to idols.
- Eze 20:31 - When you offer your gifts, sacrificing your sons in the fire, you continue to defile yourselves with all your idols to this day. So should I be consulted by you, O house of Israel? As surely as I live, declares the Lord GOD, I will not be consulted by you!
- Jer 7:31 - They have built the high places of Topheth in the Valley of Hinnom so they could burn their sons and daughters in the fire—something I never commanded, nor did it even enter My mind.
- Jer 32:35 - They have built the high places of Baal in the Valley of Hinnom to make their sons and daughters pass through the fire to Molech—something I never commanded them, nor had it ever entered My mind, that they should commit such an abomination and cause Judah to sin.
There are many more! Such abominable practices were explicitly prohibited in places such as Deut 12:29-32, Lev 18:21 and implied in Ex 20:3-6 and Deut 5:7-10.
I also note that the so-called motivation of the rebellion in Ex 32 was to hold "a feast to the LORD" (Ex 32:5). This was an excuse so that the people could indulge in revelry (V6). [I pause to note that modern gods of entertainment are no different because they involve extreme sensuality and violence.]
The same thing occurred (as correctly pointed out by the OP) in Jer 7:31. [See also Jer 7:18 - an allusion to Asherah and the "Queen of Heaven" involving sensual practices.]