The continued presence of foreign nations within the borders of the land after the era of Joshua was not a historical accident. It was a deliberate plan by God to test the new generations of Israelites who arose after the initial conquest. While the Israelites theoretically had the ability to continue eliminating these local nations, the reality on the ground was different. At times they simply lacked the desire to finish the task, and at other times they lacked the physical capability [ביאור שטיינזלץ]. As a result, God allowed these undefeated nations to remain as a permanent testing ground for the people.
The primary approach among commentators is that this test was specifically designed for the younger generation who had not personally experienced the earlier wars in Canaan. Their lack of knowledge was not merely a gap in historical facts, but a fundamental misunderstanding of how the victory was actually won. Having never witnessed the great miracles performed during Joshua's time, the new generation failed to realize that the land was not conquered through their ancestors' physical bravery or military strength. They did not grasp that it was God who had fought for them. This profound disconnect weakened their faith in God [מצודת דוד], ultimately leading them to disobey and betray Him [רש״י].
Conversely, another perspective views this lack of knowledge in a strictly practical and military light. Because God fought for the previous generation through open miracles, those earlier Israelites never actually needed to learn the strategies and tactics of conventional warfare. Therefore, God intentionally left the remaining foreign nations in place to teach the newer generations how to fight on their own, giving them the military experience they entirely lacked [אברבנאל].