“If there arise among you a prophet, or a dreamer of dreams, and giveth thee a sign or a wonder, and the sign or the wonder come to pass, whereof he spake unto thee, saying, Let us go after other gods, which thou hast not known, and let us serve them; thou shalt not hearken unto the words of that prophet, or that dreamer of dreams: for the LORD your God proveth you, to know whether ye love the LORD your God with all your heart and with all your soul. Ye shall walk after the LORD your God, and fear Him, and keep His commandments, and obey His voice, and ye shall serve Him, and cleave unto Him. And that prophet, or that dreamer of dreams, shall be put to death; because he hath spoken to turn you away from the LORD your God, which brought you out of the land of Egypt, and redeemed you out of the house of bondage, to thrust thee out of the way which the LORD thy God commanded thee to walk in. So shalt thou put the evil away from the midst of thee.” Deuteronomy 13:1-5 (KJV)
The prophet or preacher of God, the man of God is to speak the word of God. Anything contrary to the word of God is a lie. The man or woman who says God said something which God has not said is worthy of death.
I would say that God gave these verses partly due to men like Balaam who sought reward from Balak the Moabite king and people who sought to curse the children of Israel, and to lead them astray at Baalpeor (Numbers 25).
I have in my mind another prophet who stood against the prophet of God, Jeremiah. Hananiah stood against Jeremiah, and the word of God. Jeremiah pronounced that Hananiah would die within the year; and Hananiah the false prophet died that year (Jeremiah 28:11-17).
Putting evil away is through the preaching of the Word of God, and doing what God says. The man of God has a great responsibility with the word of God. We are not to twist it to please people; including ourselves. We are to proclaim it as God has spoken it. Pleasing the people to draw a crowd does not please God. The word of God is written for us to read, to hear, and to heed. See 2 Timothy 2:15.