Why did participating in idol worship warrant execution? (17:2–5) Deuteronomy 17:2-5 New English Translation (NET Bible) 2 Suppose a man or woman is discovered among you—in one of your villages that the Lord your God is giving you—who sins before the Lord your God and breaks his covenant 3 by serving other gods and worshiping them—the sun, moon, or any other heavenly bodies which I have not permitted you to worship. 4 When it is reported to you and you hear about it, you must investigate carefully. If it is indeed true that such a disgraceful thing is being done in Israel, 5 you must bring to your city gates that man or woman who has done this wicked thing—that very man or woman—and you must stone that person to death.
Deuteronomy 17:2 - 5
ESV - 2 If there is found among you, within any of your towns that the Lord your God is giving you, a man or woman who does what is evil in the sight of the Lord your God, in transgressing his covenant. 3 And has gone and served other gods and worshiped them, or the sun or the moon or any of the host of heaven, which I have forbidden.
For follow-up discussion and general commentary on the topic. Comments are sorted chronologically.