So the LORD allowed those nations to remain, not driving them out quickly; and He did not give them into the hand of Joshua. 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). Judges 2:23-3:2
Why doesn't God take away all of our old tendencies when He saves us (e.g., a temper, smoking problem, etc)? I once heard a brother answer that question using the above verse. Among other reasons, God will leave a few of our old tendencies in place to teach us to fight. That is by no means a reason to settle down to a habitual sin. On the contrary, you can be assured that God left that problem in place to show you how to beat it. He is literally going to take you in hand and teach you to fight! And we can rest assured that He leaves nothing in the land which He doesn't purpose to be destroyed (Ezekiel 36:25).