Ibn Ezra answers that we know that Bnei Yisrael fell victim to the sins of znus and avodah zarah right after Bilam’s attempt to curse them. Had Bilam been able to say what he wanted, the world would have attributed Bnei Yisrael’s failings and punishment to those curses rather than to Hashem.
Ralbag says this can’t be what is going on. The haftarah tells us to remember the kindness Hashem did for us in thwarting Bilam’s curses. According to the Ibn Ezra, we didn’t gain or lose anything from those curses – G-d gained, because the world would now correctly attribute the punishment of Bnei Yisrael to G-d rather than to Bilam. It’s a great kavod shamayim for people to know that G-d is in charge, but why is that a chessed for us?
Ralbag explains that it’s not the NY Times or Google headline that Hashem was concerned with in thwarting Bilam – it was what was in our heads that he cared about. Had Bnei Yisrael known (and it would have become known) that Bilam had put a curse on them, they would have attributed their sin and punishment not to their own bad choices, but rather to Bilam’s curse. They would have accepted the inevitability of failure and the inevitability of punishment. There can be no greater obstacle to teshuvah than that. Hashem therefore made clear that Bilam had nothing to do with the events that transpired. We were responsible for our own situation, and it was in our hands alone to correct our transgressions and bring about a return to G-d. We see an important point from this Ralbag: you don’t have to give someone a handout to do a chessed. Empowering someone so that they can take responsibility for their own fate is a chessed as well.
In defense of the Ibn Ezra, perhaps one can suggest that just as when people daven for someone who is ill, the fact that that individual (even without doing anything) serves as an instrument, a kli, to bringing about greater avodas Hashem and kvod shamayim works in his/her favor, so too on the flipside, had the punishment of Bnei Yisrael been attributed to Bilam’s curse, we would have in effect served as the instrument, the kli, of c”v reducing kvod shamayim in the world and it would have counted against us. Not putting us in a situation where we would be the tool by which chilul Hashem occurs is not just a benefit to kvod shamayim, but is a benefit for us as well.