Because you angered God
It was because you angered God
that you were handed over to your foes.
The passage goes on to reaffirm that it was God who brought calamity upon His people on account of their sin.
We should be careful in how we interpret this, neither to assume, on the one hand, that God works in the same way as human vengeance, or, on the other hand, to dismiss as obsolete those parts of this Old Testament passage we do not like.
First of all, it is clear that it is our own sin and disobedience (as individuals and as a world) that is the ultimate cause of our calamities.
Second, we live in a universe of consequences: consequences that are natural and intrinsic, even though human intelligence does not always perceive them.
Third, when God lets these calamities befall us, it is both His “follow-through” on the gift of Free Will that He gave us and also His providing us opportunities to grow in charity and spiritual strength.
Finally, the main intent of the passage is that although we brought these things upon ourselves by our sins (we as individuals and we as a world) and God let these things happen, He is right there at our side with His all-powerful promise of mercy, healing, and eternal joy.
Fear not, my children;
call out to God!
He who brought this upon you
will remember you.
As your hearts have been disposed to stray from God,
turn now ten times the more to seek him;
For he who has brought disaster upon you
will, in saving you, bring you back enduring joy.
Lord Jesus Christ, Son of the living God, be merciful to me - a sinner.