2 "If there is found among you, within any of your gates which the Lord your God gives you, a man or a woman who has been wicked in the sight of the Lord your God, in transgressing His covenant, 3 who has gone and served other gods and worshiped them, either the sun or moon or any of the host of heaven, which I have not commanded, 4 and it is told you, and you hear of it, then you shall inquire diligently. And if it is indeed true and certain that such an abomination has been committed in Israel, 5 then you shall bring out to your gates that man or woman who has committed that wicked thing, and shall stone to death that man or woman with stones. 6 Whoever is deserving of death shall be put to death on the testimony of two or three witnesses; he shall not be put to death on the testimony of one witness. 7 The hands of the witnesses shall be the first against him to put him to death, and afterward the hands of all the people. So you shall put away the evil from among you.

Matthew Henry's Commentary on Deuteronomy 17:2-7

Commentary on Deuteronomy 17:1-7

(Read Deuteronomy 17:1-7)

No creature which had any blemish was to be offered in sacrifice to God. We are thus called to remember the perfect, pure, and spotless sacrifice of Christ, and reminded to serve God with the best of our abilities, time, and possession, or our pretended obedience will be hateful to him. So great a punishment as death, so remarkable a death as stoning, must be inflicted on the Jewish idolater. Let all who in our day set up idols in their hearts, remember how God punished this crime in Israel.