The 'Goat-Demon' Idolatry
Commentators explain that the 'he-goats' (or 'devils') refer to goat-like deities worshipped in Egypt. The Israelites had likely adopted this idolatry, which involved debased rituals described as spiritual 'harlotry.' This command was a direct prohibition against a specific, corrupting pagan practice they had brought with them into the wilderness. Scholars note this is the origin of the popular medieval image of the devil with horns and cloven feet.