There is a fundamental problem regarding Bilam’s attempt to curse Bnai Yisrael in Parshat Balak. Why would Hashem worry or even care about Bilam’s desire to curse Bnai Yisrael? Even if he had been successful in cursing them, how could it have had any effect? After all, the Torah previously told us, לא תנחשו ולא תעוננו, “You shall not indulge in sorcery, and you shall not believe in lucky times” (Vayikra 19:26), אל תפנו אל האבת ואל הידענים, “Do not turn to [the sorcery of] the Ovot and Yidonim” (ibid. 19:31), לא ימצא בך...קסם קסמים מעונן ומנחש ומכסף, “There shall not be found among you…one who practices divinations, an astrologer, one who reads omens, or a sorcerer” (Devarim 18:10), and כי הגוים האלה...אל מעננים ואל קסמים ישמעו ואתה לא כן נתן לך ה' אלקיך, “For these nations…they hearkened to astrologers and diviners; but as for you – not so has Hashem, your God, given to you” (ibid. 18:14).
The Daat Mikra answers that indeed, Hashem was not worried about the possibility of Bilam’s curse taking effect. Rather, He was concerned that Bilam’s curse might give Moav the confidence and courage to attack Bnai Yisrael. This was a scenario that Hashem wanted to avoid. Therefore, by having Bilam bless Bnai Yisrael, the opposite effect was achieved: Balak and Moav’s fear of Bnai Yisrael only increased.