There are numerous difficulties in the narrative of Parshat Balak. First of all, Abarbanel is puzzled by the fact that Gd is angry with Bilaam for going to curse the Bnei Yisrael, after having apparently given him permission to do so. Secondly, why in the end does G-d prevent Bilaam from doing so? Could the curse of Bilaam actually have any power over Bnei Yisrael? Abarbanel cites the opinion of the Ibn Ezra, who states that since Gd later in Shittim brings a plague on the people, others would attribute this punishment erroneously to the curse of Bilaam rather than the transgressions of the people. Abarbanel disagrees with this answer and demonstrates from a verse in the Prophet Micah (6:5) that if it weren’t for G-d’s merciful intervention Bilaam’s curse would indeed have taken effect: “He summoned Bilaam… to curse you. But I refused to listen to Bilaam… thus I rescued you from his power.” In addition, Yehoshua mentions the miracle that G-d performed in rescuing us from Bilaam’s curse in his list of the miracles that G-d performed on behalf of the Bnei Yisrael. (Yehoshua 24:9)
In regard to the first question, Abarbanel answers that G-d gave Bilaam permission to go with the messengers of Balak, but He did not give him permission to curse anyone. Rather G-d made it clear to him, “That which I tell you to say, you will say”. This could mean that he should bless them, or could mean that he should curse them or could mean to not say anything at all. However, G-d was clearly not giving Bilaam carte blanche to curse Bnei Yisrael. Bilaam should have understood that since G-d did not intend for him specifically to curse them, there was no point in his going with the messengers. Bilaam should have clearly explained to them that he would go with them, but there would be no purpose and nothing to be gained from their requests at all. However, he misled them by telling them that G-d had given him permission to go with them. As a result, he incurred the wrath of G-d.
Thus, G-d prevented Bilaam from cursing the people, but not because he had the power to uproot the merit of the Forefathers and the merit of the entire nation at Mount Sinai. Rather the whole world knew that Bilaam was a prophet who inquired of G-d, as Balak himself stated at the beginning of the Parsha, “Because I know that those whom you bless are blessed and those whom you curse are cursed.” (Bamidbar 22:6) As a result, if Bilaam had cursed Bnei Yisrael, the nations of the world would have trusted his curse, girded themselves for warfare and been courageous and confident of success on the basis of that curse. Therefore, G-d intervenes and prevents the curse from occurring. All the nations would realize that the success of Bnei Yisrael comes directly from G-d. They would no longer have the courage to stand up against them. When that curse is turned into a blessing, Bilaam’s attempt to curse Bnei Yisrael is turned to Bnei Yisrael’s advantage, as it weakens even further any opposition to their goal of entering and conquering the nations inhabiting the land of Canaan. This is what Rachav says to the spies sent by Yehoshua to reconnoiter Jericho, “I know that G-d gave you the Land, because the fear and dread of you has fallen upon us.” (Yehoshua 2:9) How did Rachav know this? From the words of blessing of Bilaam. Thus the entire episode of Bilaam should be considered as an example of the great kindness that G-d performs on behalf of his nation, Israel.