That is what God said, but I believe we should examine this from all angles before we judge God.
We should always consider the basics of a matter before we go on to more complex parts of the problem.
The first thing to consider would be death. Everyone must die a physical death: the first death. So if God said someone, or all of a nation must be destroyed it only means that they die earlier than if they were allowed to live until they were very old.
If one is going to blame God for commanding a nation be destroyed, in order to be consistent, they would have to blame God for all death. But then you would have to believe there is a God and the next step in that line of thought would be God made life and therefore has every right to end it.
It seems that mankind wants to hold God to a standard that they, themselves would not embrace. If a man makes a chair, paints a picture, writes a book, or even makes a buck he considers it his and if someone would tell him what to do with it they would very quickly be told where to go and what to do when they got there. Yet we are quick to judge God for what He does with His possessions.
If God made everything that was made then He has every right to do with it as He pleases, but because we think life belongs to the person our view of what is right is compromised. We did not give ourselves life, so it doesn’t belong to us; it really belongs to God.
Having said that God was not unjust in commanding Israel to destroy all of life in the nations that lived in the land He gave them. He told them that if they were allowed to live in the land that they would cause God’s people to turn to other gods. That would cause His people to die the second death (separation from God), and that death is the more important of the two. The first death is mandatory, but the second death is not.
God is not cruel. He did not say destroy them all first. He said drive them out of the land (Num 33:52) and destroy their idols and places of worship. If they left, as I understand it, they would not have been destroyed.
God set the same standard for His own people. If they turned to other gods they were also to be destroyed (Deu 13:12-16). It is not that He hates them as much as they will cause others to lose their place in Heaven.
Just to put it together these people were going to die anyway (so are we) and it would be better that they died before they caused God’s people to sin against God and lose their eternal place in Heaven with God.