Then the LORD spoke to Moses, saying,
“You shall also say to the sons of Israel:
‘Any man from the sons of Israel or from the aliens sojourning in Israel who gives any of his offspring to Molech, shall surely be put to death; the people of the land shall stone him with stones.
‘I will also set My face against that man and will cut him off from among his people, because he has given some of his offspring to Molech, so as to defile My sanctuary and to profane My holy name.
‘If the people of the land, however, should ever disregard that man when he gives any of his offspring to Molech, so as not to put him to death, then I Myself will set My face against that man and against his family, and I will cut off from among their people both him and all those who play the harlot after him, by playing the harlot after Molech.
‘As for the person who turns to mediums and to spiritists, to play the harlot after them, I will also set My face against that person and will cut him off from among his people. (Leviticus 20:1-6)
Molech was a god worshiped by sacrificing children to him. Often they were sacrificed in the Hinnom Valley near Jerusalem. Child sacrifice happened regularly from the time the people of Israel entered the land until the Babylonian captivity.
God warned the Israelites against the practice in the very earliest Mosaic legislation, where the worship of other gods and seeking out mediums and spiritists was compared to prostitution. The image of adultery would later be used by the Hebrew prophets as a metaphor for Israel’s unfaithfulness to God. Mediums and spiritists sought aid from those who had died. Like idolatry it was forbidden, but the Israelites freely ignored God’s prohibitions. Even Saul, Israel’s first king, wound up consulting a medium at the end of his life (1 Samuel 28:7).
God promised judgment against those who worshiped other gods or sought guidance that should only come from God. It was not just jealousy that motivated God’s prohibition. It was a mercy: the other gods did not exist. Mediums and spiritists could not contact the dead. Putting faith and trust in that which does not exist is both a waste of time and ultimately dangerous, akin to trusting in sugar pills when only an operation can save you.