We have a hard time understanding the consequences of extreme evil and wickedness in a nation. God had already resorted to the destruction of early mankind when he saved only Noah and his family. The Canaanite nations were another such problem of evil.
God told Abraham what was going to happen in the future, and there's an interesting phrase in Gen 15:13-16:
And he said unto Abram, Know of a surety that thy seed shall be a stranger in a land that is not theirs, and shall serve them; and they shall afflict them four hundred years; And also that nation, whom they shall serve, will I judge: and afterward shall they come out with great substance. And thou shalt go to thy fathers in peace; thou shalt be buried in a good old age. But in the fourth generation they shall come hither again: for the iniquity of the Amorites is not yet full.
In other words, the Amorites (and other Canaanite nations) were becoming so wicked that God would have to remove them, but they would still have another 400 years to reject God and become ever more despotic.
A similar situation existed with the Amalekites. In 1 Samuel 15:2-3, God commanded Saul and the Israelites, “This is what the LORD Almighty says: 'I will punish the Amalekites for what they did to Israel when they waylaid them as they came up from Egypt. Now go, attack the Amalekites and totally destroy everything that belongs to them. Do not spare them; put to death men and women, children and infants, cattle and sheep, camels and donkeys.'" God ordered similar things when the Israelites were invading the promised land (Deuteronomy 2:34; 3:6; 20:16-18).
We have to trust that God is both just and as compassionate as He can be. We know that His ways and thoughts are higher than ours (Isaiah 55:9; Romans 11:33-36). Unlike us, God knows the future.
God knew what the results would be if Israel did not completely eradicate the Amalekites. If Israel did not complete God’s orders, the Amalekites would come back to “haunt” the Israelites again and again. Saul claimed to have killed everyone but the Amalekite king Agag (1 Samuel 15:20). Obviously Saul was lying…just a couple of decades later there were enough Amalekites to take David and his men’s families captive (1 Samuel 30:1-2). After David and his men attacked the Amalekites and rescued their families, 400 Amalekites escaped. If Saul had fulfilled what God had commanded him, this never would have occurred. Several hundred years later, a descendant of Agag, Haman, tried to have the entire Jewish people exterminated (see the book of Esther). So, Saul’s incomplete obedience almost resulted in Israel’s destruction. God knew this would occur, so He ordered the extermination of the Amalekites ahead of time.
In regards to the Canaanites, God commanded, “However, in the cities of the nations the LORD your God is giving you as an inheritance, do not leave alive anything that breathes. Completely destroy them — the Hittites, Amorites, Canaanites, Perizzites, Hivites and Jebusites — as the LORD your God has commanded you. Otherwise, they will teach you to follow all the detestable things they do in worshiping their gods, and you will sin against the LORD your God” (Deuteronomy 20:16-18). The Israelites failed in this mission as well, and exactly what God said would happen occurred (Judges 2:1-3; 1 Kings 11:5; 14:24; 2 Kings 16:3-4). God did not order the extermination of these people to be cruel, but rather to prevent even greater evil from occurring in the future.