The pessukim mention a few things which Bilam tried to do to curse Yisrael, yet he was not successful.
Balak requested that Bilam should curse Yisrael to which Bilam responded, “return to your land כי מאן ה’ לתתי להלך עמכם” which Onkelos translates as “there is not favor before Hashem to go with you.” Balak requests again, to which Bilam responds “לא אוכל לעבור את פי ה’” which Onkelos translates as “I am not permitted to transgress the decree of Hashem to do anything small or big.” Bilam was not shown favor and was not granted permission to go. Even so, Bilam took an ass and went to curse Yisrael. Hashem first made the ass turn off the road, then caused it to smash Bilam’s foot against the wall, and lastly caused the ass to crouch down in its place. Although Bilam tried going, Hashem stopped him and then said, “The message that I will speak with you, it you shall say.”
The passuk states, “וישם ה’ דבר בפי בלעם and He placed the message in his mouth.” Rashi explains when Bilam heard that he was not permitted to curse he said, “Why should I return to Balak and cause his anguish.” Hashem put into Bilam’s mouth a bit, like reigns, which forces animals to move against their will. So too Hashem forced Bilam to return.
The passuk states הנה ברך לקחתי וברך ולא אשיבנה which Onkelos translates as “behold I accepted berachos, I will bentch Yisrael and I will not return my berachos from the nation.” The Nefesh HaGer explains that Bilam was forced to consent to say berachos. He said about himself, “I will bentch Yisrael to my dissatisfaction, without having the ability to stop.” Bilam had pain that he was unable to curse Yisrael and was forced instead to say blessings while trying to say words of curse. Balak asked Bilam, “What are you doing blessing Yisrael and not cursing them?” Bilam responded, “Believe me that I hate Yisrael even more than you, and I wanted to curse them. However I saw a wondrous thing happening to myself. When I opened up my mouth to curse Yisrael with my whole heart and soul, an angel came and pushed away the curses from my mouth. He caused the five parts of the mouth which enable speech to change my words into berachos.” This is as the passuk states ויהפך ה’ אלוקיך לך את הקללה לברכה Hashem changed the words of curse into berachos against Bilam’s will. Suddenly Bilam stated hearing words of berachah ringing in his ears to his misbelief and to his disappointment.
When Balak heard this he said, “גם קב לא תקבנו גם ברך לא תברכנו, not only do not curse them but also don’t bless them.” The Nefesh HaGer asks, Balak sent Bilam for this exact purpose, to curse Yisrael, so why did he say “do not curse?” Also, why did he need to say “do not bless,” this is obvious? The Nefesh HaGer answers, Balak said, “Whatever you wanted to curse all turned into berachos, so do not even curse them. The curses themselves will turn into berachos, it is better off that you remain quiet.” Bilam responded, “I told you כל אשר ידבר ה’ אותו אעשה, whatever Hashem will speak, it I will do. Even being quiet is not in my control, I am not a master about that either and I can’t hold back a prophecy which I receive.”
We see that Hashem did not permit Bilam to go, and stopped Bilam when he went, made him go when he didn’t want to, forced him to say berachos in place of klalos, and did not allow him to remain silent. This as the passuk states “כי אהבך ה’ אלקיך because Hashem your G-d loves you.”