To wake them up and get them back on track as the model nation He had originally intended, God gave Israel over to their enemies. Israel repented and cried out to God. God rescued them. With their bellies full and lives protected, the Israelites went back to pursuing other gods. God punished Israel again. Israel repented and cried out to God.
And so went the deliverance-idolatry-punishment-repentance cycle (vs. 40-46), until finally, God had no other choice but to divorce unfaithful Israel (Jer. 3:6-11).