Deuteronomy 20:18

18 so that they teach you not to do according to all their abominations which they have done to their gods, and ye have sinned against Jehovah your God.

Deuteronomy 20:18 Meaning and Commentary

Deuteronomy 20:18

That they teach you not to do after all their abominations,
&c.] This is another reason why they were to be utterly destroyed, not only because of the abominations which they committed, but to prevent the Israelites being taught by them to do the same; wherefore, as before observed from Jarchi, such as became proselytes were suffered to live among them, because there was no danger of idolatry from them, which even proselytes of the gate renounced; and though all other abominations are included, yet this is particularly respected, as appears from the following clause:

which they have done unto their gods;
to the honour of whom not only many superstitious rites and ceremonies were performed, and idolatrous actions committed, but acts of lewdness, and even unnatural uncleanness:

so should ye sin against the Lord your God;
a sin the most provoking to him, as the sin of idolatry was; and cause his anger to rise to such a degree, as to suffer them to be carried captive from the land he gave them to inherit; and which afterwards, was the case, and that through learning the manners and customs of these people; see ( Psalms 106:34-42 ) .

Deuteronomy 20:18 In-Context

16 `Only, of the cities of these peoples which Jehovah thy God is giving to thee [for] an inheritance, thou dost not keep alive any breathing;
17 for thou dost certainly devote the Hittite, and the Amorite, the Canaanite, and the Perizzite, the Hivite, and the Jebusite, as Jehovah thy God hath commanded thee,
18 so that they teach you not to do according to all their abominations which they have done to their gods, and ye have sinned against Jehovah your God.
19 `When thou layest siege unto a city many days, to fight against it, to capture it, thou dost not destroy its trees to force an axe against them, for of them thou dost eat, and them thou dost not cut down -- for man's [is] the tree of the field -- to go in at thy presence in the siege.
20 Only, the tree, which thou knowest that it [is] not a fruit-tree, it thou dost destroy, and hast cut down, and hast built a bulwark against the city which is making with thee war till thou hast subdued it.
Young's Literal Translation is in the public domain.