#Why would Yahweh not drive out from Israel any of the nations that Joshua left when he died?

Yahweh would not drive out from Israel any of the nations that Joshua left when he died, so that Yahweh could test Israel, whether or not they would keep the way of Yahweh and walk in it, as their fathers kept it. [2:21-22]