God told Israel to destroy all Canaanites and cleanse the land of Canaan.
As Israel was preparing to enter the land of Canaan, GOD told Moses:
50 Now the Lord spoke to Moses west of Moab by the Jordan opposite Jericho, saying, 51 “Speak to the children of Israel and say to them, ‘You are crossing over the Jordan into the land of Canaan. 52 Then you shall destroy all the inhabitants of the land before your face; and you shall remove their high places, and as for all their molten idols, you shall destroy these; and you shall remove all their pillars. 53 You shall also destroy all the inhabitants of the land and dwell in it, for I give you their land as an inheritance. 54 Therefore you shall inherit their land by lot among your tribes; to the larger you shall give a larger inheritance, and to the smaller you shall give a smaller inheritance; there everyone’s inheritance shall be whatever falls to him by lot. You shall inherit according to the tribes of your fathers. 55 But if you do not destroy the inhabitants of the land from before your face, it shall be that those whom you let remain shall be thorns in your eyes and arrows in your sides; and they shall be at enmity with you in the land where you dwell. 56 Moreover, it shall be that I will do to you as I thought to do to them.’”Numbers 33:50-56 OSB
Special instructions were given for the Amalekites because of what they had done to Israel earlier:
17 “Remember what Amalek did to you on the way as you were coming out of Egypt, 18 how he met you on the way and cut off your rear guard, all the stragglers at your rear, when you were tired and weary; and he did not fear God. 19 Therefore it shall be, when the Lord your God gives you rest from your enemies all around in the land the Lord your God is giving you to possess as an inheritance, you will blot out the name of Amalek from under heaven. You shall not forget.Deuteronomy 25:17-19 OSB