“They were left to test Israel, so the Lord would know if his people would obey the commands he gave their ancestors through Moses.”
God tested Israel by leaving some pagan nations in the land. Unfortunately, they failed the test, permitting themselves to be influenced to commit idolatry and immorality.
Every test ought to be seen as an opportunity to demonstrate faithfulness to God. He desires to see us pass tests with flying colors.