The Lord wanted Israel to see that he was true to his threats as well as his promises, and strictly abided by what He had spoken and sworn (Exodus 23:33; Leviticus 26:17, Leviticus 26:25, Leviticus 26:36–37; Deuteronomy 28:25, Deuteronomy 28:29; Joshua 23:12–13, Joshua 23:15–16)…. It is also clear from this that God had not yet abandoned the Israelites entirely. His punishments were motivated by the covenantal relationship that He continued to maintain, and their purpose was to lead His people to repentance.
1
15 Whenever they marched out, the hand of the LORD was against them for harm, as the LORD had warned, and as the LORD had sworn to them. And they were in terrible distress.