Deuteronomy 23:5

5 ut the LORD your God refused to listen to Balaam. Instead, he turned Balaam's curse into a blessing for you because the LORD your God loves you.