This was because the people of Ammon and Moab did not give food and water to the Israelites on their way out of Egypt. Instead, they paid money to Balaam to curse Israel, but our God turned the curse into a blessing.
that a people who came from Egypt has spread out over the whole land. He wants me to curse them for him, so that he can fight them and drive them out.”