171 Do not sacrifice to the Lord your God an ox or a sheep that has any defect or flaw in it, for that would be detestable to him. 2 If a man or woman living among you in one of the towns the Lord gives you is found doing evil in the eyes of the Lord your God in violation of his covenant, 3 and contrary to my command has worshiped other gods, bowing down to them or to the sun or the moon or the stars in the sky, 4 and this has been brought to your attention, then you must investigate it thoroughly. If it is true and it has been proved that this detestable thing has been done in Israel, 5 take the man or woman who has done this evil deed to your city gate and stone that person to death. 6 On the testimony of two or three witnesses a person is to be put to death, but no one is to be put to death on the testimony of only one witness. 7 The hands of the witnesses must be the first in putting that person to death, and then the hands of all the people. You must purge the evil from among you.

Matthew Henry's Commentary on Deuteronomy 17:1-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.