This was because they had refused to give food and water to Israel and had hired Balaam to call down a curse on them. However, our God turned the curse into a blessing.
Don't forget the evil plans of King Balak of Moab or what Balaam son of Beor said to him. Remember how I, the LORD, saved you many times on your way from Acacia to Gilgal.
They have left the true road and have gone down the wrong path by following the example of the prophet Balaam. He was the son of Beor and loved what he got from being a crook.