Deuteronomy 31:17

Then my anger shall be kindled against them in that day, and I will forsake them, and I will hide my face from them, and they shall be devoured, and many evils and troubles shall befall them; so that they will say in that day, Are not these evils come upon us, because our God is not among us?

When Israel turns to other gods and breaks its covenant, God kindles His anger to forsake them, hide His face from them, and withdraw His protection and presence, so that they are devoured and many evils and troubles befall them. When His people willfully refuse His covenant and reject His appeals, He withdraws His presence and covenant-keeping power and leaves them to follow their chosen way to destruction. That withdrawal is brought about by not taking heed to the word of God, by not receiving reproof and correcting the ways, by trifling with great privileges despite the wondrous things He has wrought, by setting at naught His counsels, and by joining with idolaters.

Jerusalem's ruined walls and broken gates and Israel's reduction in power and honor among the nations came because God withdrew His special presence and protection for such unfaithfulness. The withdrawal of the light of His presence brings trouble and confusion, weakens the ranks of His people, and gives unbelievers and the enemy occasion to reproach the Lord. Under the resulting evils the people are led to say that these calamities have come because God is not among them. The song Moses was commanded to teach was to remain as a witness against the people when this came to pass.