In the opening verses of Judges 3, there's an apparent contradiction:
1 Now these are the nations that the Lord left, to test Israel by them, that is, all in Israel who had not experienced all the wars in Canaan. 2 It was only in order that the generations of the people of Israel might know war, to teach war to those who had not known it before. 3 These are the nations: the five lords of the Philistines and all the Canaanites and the Sidonians and the Hivites who lived on Mount Lebanon, from Mount Baal-hermon as far as Lebo-hamath. 4 They were for the testing of Israel, to know whether Israel would obey the commandments of the Lord, which he commanded their fathers by the hand of Moses. 5 So the people of Israel lived among the Canaanites, the Hittites, the Amorites, the Perizzites, the Hivites, and the Jebusites. 6 And their daughters they took to themselves for wives, and their own daughters they gave to their sons, and they served their gods. [Judges 3:1-5, ESV]
Verse 2 seems to say that the only reason God allowed some Canaanites to remain in the land and not be destroyed is so that future generations of Israelites who weren't part of the conquest would learn warfare. Verse 4 seems to say that God allowed the nations to remain in the land as a test for Israel of whether they would follow the Torah or revert to the Canaanites' ways.
There are those who conclude that these two verses must have been written by two different authors who had conflicting agendas, and somehow and for unfathomable reasons they got combined by some idiot who couldn't tell they flat-out contradicted each other. If you thought ancient writers or editors were either stupid or unconcerned with telling a coherent narrative, then you might be attracted to such a theory, but most decent literary interpretation tries to make sense of the text rather than trying to read it in the least charitable way possible. So it would be nice to find an explanation that doesn't make the author or final compiler look like a complete dunce.
I think the apparent inconsistency disappears if you think of learning warfare not as learning how to fight (which doesn't seem to be the sort of thing God ever emphasizes in the Bible anyway and wouldn't matter if there were no enemies anyway) but rather as knowing the experience of being at war. Why would God want them to have the experience of war? Verse 4 explains that. If this is right, then verses 2 and 4 aren't providing contrary explanations but are emphasizing different aspects of the same explanation. It may not be the most natural interpretation of verse 2 if that verse were taken in isolation, but these other factors should count for something.