In this chapter, Moses commands the people to slay anyone who turns away from following the LORD.
There are three categories in this chapter, which I will address in order. The first category is false prophets, the second category is fellow Israelites who turn away from the LORD (but without any prophetic statements), and the third category is entire cities that turn away from the LORD. Just as with the last chapter, I don't really know which commandment this chapter is associated with. Some commentators suggest this chapter relates to the third commandment (honoring the name of the LORD) and I really don't see how that's more appropriate than the first commandment (no other gods before the LORD). I can't say more without looking into the matter more carefully.
The first group is probably the most interesting. We have seen prophets on many occasions (cf. Gen 20:7, Ex 7:1, Ex 15:20, Num 12:6), and all of those instances are indicative of what is a prophet. Num 12:6 in particular reveals that prophets are those to whom the LORD makes himself "known to him in a vision. I shall speak to him in a dream." We have seen the LORD speak to numerous people through dreams (such as Jacob's dream in Gen 28) and visions (for instance, Abraham's vision in Gen 15:12-17. Abraham is separately called a prophet in Gen 20:7). We also learned that prophets were responsible for speaking on behalf of their respective gods in Ex 7:1.
What this chapter teaches us is that false prophets are not known by giving false signs; they are capable of giving true signs and wonders. Rather, they are false by virtue of "counseling rebellion against the LORD". This is really just another expression of the first commandment, refusing to follow any gods besides the LORD no matter who is talking to you, even if it is a prophet who "gives you a sign or a wonder" and it comes true. I think this is interesting because in modern culture, we largely discount the possibility of miracles at all. However, the author of Deuteronomy accepts both the possibility of miracles from the LORD (many of which are documented in the Pentateuch) and also miracles performed by prophets or "dreamers of dreams" who speak on behalf of other gods.
As a minor note, I love the phrase "dreamer of dreams". In Hebrew, it is "chalam chalom", which is amusingly redundant for such an otherwise-terse language. That is, Hebrew is usually ambiguous, omitting many words. This is not one of those cases. :)
The second group is individuals who turn away from the LORD and try to persuade others to also worship other gods. Just as with the false prophet, anyone who tries to convince you to abandon the LORD must be put to death for breaking the covenant and the first commandment. The key to understanding this section is verse 6, which emphasizes closeness. Be it "son, or daughter, or wife who is close to you, or the companion of your soul" (v. 6), they all must die if they turn away from the LORD and try to "secretly entice" you to do likewise.
This is in a society that deeply values family and community, so committing a family member to death is incredibly serious. That's what the covenant demands; it is a commitment above every other. Love for the LORD must supersede love for every human in your life. Verses 8-9 show the severity of this commitment, because it's not enough to follow the LORD and conceal this friend's treachery. It's not enough to "just" denounce that person to the community; your hand must be the "first against him to put him to death". The purpose is to extinguish any empathy for the crime of serving other gods by directly acting against this person whom you love.
The third group is entire cities that serve other gods. In this case, similar to the other cases, one must investigate to discover if the city truly turned away from the LORD, and if so, put everyone in the city to death and burn it. It must be blotted out like Sodom and Gomorrah, with everything burned in fire. This is similar to the repeated expression "cut off" that we saw through Exodus and Leviticus, that people who break laws in the covenant "shall be cut off from among his people", which either means permanent exile or more likely, death.
This chapter uses a uniquely Deuteronomy expression, "you shall purge the evil from among you". This expression is only used in Deuteronomy and a related form appears once in Judges 20:13 ("...we may put them to death and purge the evil from Israel"). This is one of the several linguistic differences between Deuteronomy and the rest of the Pentateuch, but conceptually it speaks of the same thing; cutting off or destroying sinful activity from the midst of Israel to protect the people from the corrupting influence.
In the case of the third group, it is more than just a sinful individual: sinful cities must also be wholly destroyed. This is similar to the destruction of the native Canaanite tribes who commit abominations such as child sacrifice (Deut 12:31). As the LORD threatens on many occasions, if the Israelites adopt the customs of the other nations and serve other gods, they must be destroyed. If the Israelites do not destroy a sinful town, the rest of the nation is subjected to the LORD's "burning anger", like the many plagues they suffered in the wilderness.
What the LORD is looking for is zeal, like the zeal of the Levites (Ex 32:25-29) or the zeal of Phinehas (Num 25:7). The LORD is looking for zeal amongst Israel to destroy everyone who turns from the LORD, no matter how powerful or precious or many. There should be no compromise, no negotiation, no mercy for all those who break the covenant and turn away.