Good question.
The Bible tells us the answer:
"Now these are the nations which the Lord left, to test Israel by them (that is, all who had not experienced any of the wars of Canaan; only in order that the generations of the sons of Israel might be taught war, those who had not experienced it formerly). These nations are: the five lords of the Philistines and all the Canaanites and the Sidonians and the Hivites who lived in Mount Lebanon, from Mount Baal-hermon as far as Lebo-hamath. They were for testing Israel, to find out if they would obey the commandments of the Lord, which He had commanded their fathers through Moses. The sons of Israel lived among the Canaanites, the Hittites, the Amorites, the Perizzites, the Hivites, and the Jebusites; and they took their daughters for themselves as wives, and gave their own daughters to their sons, and served their gods." (Judges 3:1-6)
So the Lord left the nations there to test Israel, to see whether the Israelites would obey God and not serve the other gods. But history shows that the Israelites were disobedient.
God did not defeat the nations miraculously without any fighting, because only with fighting and involvement of the Israelites directly, would they know how to obey God and trust Him.
Sometimes God lets us experience difficulties and problems so that we can grow through them. Requiring the Israelites to fight is a difficulty that also required them to trust God fully. If the Israelites trusted God and obeyed His commandments to serve God only, then they could have defeated all their enemies.
Because king David was a man after God's heart (Acts 13:22), he was very successful in war. David led the Israel army to worship God and follow Him. So the Lord gave the Philistines into David's hand. David defeated Goliath (a Philistine) and won many battles against the Philistines.
Learning to physically fight in a war is a life and death situation for every fighter. Only through personal experience of such a great hardship can a person grow greatly. Usually humans grow much more during difficulties than during fair-weather times. This is why God uses difficulties to help us grow.
Even the apostle Paul grew a lot through the hardships he faced (2 Corinthians 12:9-10).
Furthermore, the physical fighting in Old Testament times is a foreshadowing of the spiritual warfare we face.
In the time of Jesus and the church age, we don't physically fight religious wars but spiritually fight them.
"For our struggle is not against flesh and blood, but against the rulers, against the powers, against the world forces of this darkness, against the spiritual forces of wickedness in the heavenly places." (Ephesians 6:12)
So our spiritual battles are against sin, doubt, and temptations.
The Bible teaches us how to fight:
"Therefore, take up the full armor of God, so that you will be able to resist in the evil day, and having done everything, to stand firm. Stand firm therefore, having girded your loins with truth, and having put on the breastplate of righteousness, and having shod your feet with the preparation of the gospel of peace; in addition to all, taking up the shield of faith with which you will be able to extinguish all the flaming arrows of the evil one. And take the helmet of salvation, and the sword of the Spirit, which is the word of God." (Ephesians 6:13-17)
While the Old Testament battles paint for us what physical war was like against the nations that didn't believe in God, the New Testament gives us the full picture of what spiritual warfare is. It is against the temptations and doubts that the evil one throws at us. And it is against the spiritual enemies and bad angels in the spiritual places.
The Old Testament wars give an allegorical picture of our present spiritual warfare. So another reason God wanted the Israelites to physically fight is that the good fighters can be role models for us today.
So let us be like David and fight!
David said:
"For You are my lamp, O Lord;
And the Lord illumines my darkness.
For by You I can run upon a troop;
By my God I can leap over a wall.
As for God, His way is blameless;
The word of the Lord is tested;
He is a shield to all who take refuge in Him...
He makes my feet like hinds’ feet,
And sets me on my high places.
He trains my hands for battle,
So that my arms can bend a bow of bronze.
You have also given me the shield of Your salvation,
And Your help makes me great.
You enlarge my steps under me,
And my feet have not slipped.
I pursued my enemies and destroyed them,
And I did not turn back until they were consumed." (2 Samuel 22: 29-31,34-38)