The people of Canaan, whom God commanded to be killed, were being punished just like Sodom and Gomorrah was punished and like the world in Noah's day was punished. The whole earth had become corrupt in Noah's time with sexual sins (Gen.6:11). The Canaanites too were indulging in degrading sexual sins and Satan worship. And so "the land itself spewed them out". (Leviticus 18:24,25).Deuteronomy 9:4 and18:10-12 give us clear reasons as to why God destroyed the Canaanites. Where there are polluting influences in any nation that defile and corrupt the land, the only thing to do is to punish such a nation by eliminating the people - lest their influence spread and corrupt others too.
A God of love destroys some people just like a kind doctor amputates a man's foot when the gangrene in his foot is so severe that it threatens to destroy the whole body. If you saw a doctor sawing off somebody's leg, and did not understand medicine, you would imagine that the doctor hated that man. But actually the opposite would have been true. The doctor was doing it in love. God also acts in love for the world when He cuts off certain people who would otherwise corrupt it. Wiping out the world's population at the time of the flood was an act of love, so that the human race could be preserved without being totally controlled by demons (Gen.6:2- where the "sons of God"refer to God's creation - the angels who fell). The apostle Paul once smote a man with blindness because he was leading another person astray (Acts.13:8-12). I have heard of cases of people who were smitten dead by God because they opposed a revival. So what we read of in Joshua was not the murder of the Canaanites. It was surgery for the world.
Many years earlier, when Abraham was living in Canaan, there were Canaanites there. But God did not destroy the Canaanites then. God waited for over 400 years, because, as He told Abraham, the Canaanites were not "ripe for judgment" at that time (Gen.15:16). We pluck mangoes when they are ripe. God also waits for man's sin to become ripe for judgment, before He judges. He judged Sodom and Gomorrah when their sin was ripe. So too with the Canaanites.
After Israel had occupied Canaan for 700 years, when they committed the same sins as the Canaanites, God drove them out of the land too. The Assyrians came and captured them. One hundred and twenty-five years later, when Judah, the southern kingdom, rejected the messages of God's prophets and ripened for judgment, God sent the Babylonians to destroy them too. God is not partial. Whether it be the Canaanites or the Israelites or the people of Judah, His standards are the same. If His people keep on violating His standards and ignoring His prophets, He performs the same surgery on them too. God does the same with us too. If God were to excuse your sin, it would prove that He did not love you. If a father were to allow his children to live with their diseases, it would prove that he did not really love his children.