The Lord Rejects Saul as King
15 Samuel said to Saul, “I am the one the Lord sent to anoint you king over his people Israel; so listen now to the message from the Lord. 2 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. 3 Now go, attack the Amalekites and totally destroy[a] all that belongs to them. Do not spare them; put to death men and women, children and infants, cattle and sheep, camels and donkeys.’”
In the Bible, God also has a habit of ordering extreme actions for the purpose of teaching us His ways and values (A bit like a parent). Sometimes these things are not practical in the sense of time and the use of material resources (from a human standpoint) but they can be powerful object lessons concerning Holiness, Zeal for the Lord, Obedience etc. The above is a good example of that, and likewise I see God's prescription against the Canaanites as being that as well.