Balaam tried everything to earn his fee from Balak: pestering God until He gave permission to go, prostrating himself before the angel of the Lord, sacrificing animals three times on high places (of Baal, no less), and just waiting. Nothing worked. In the end, all he could speak were blessings over Israel.
Balaam’s first two encounters with God were probably in the form of a dream (“God came to him”, the same expression used for God speaking to Abimilech and Laban), in which God revealed who He was.
The third encounter was quite likely to have been humiliating. Here was Balaam, famous for his ability to see into the spiritual world and make curses and blessings that worked. He became Balaam who couldn’t control a donkey, who then started beating it before talking to it, and who then finally fell face down before an angel that appeared to a donkey before him!
This forced Balaam to say to Balak shortly afterwards:
22:38 Look, now I have come, but I have no power to say whatever I want. I will speak only the message that God puts in my mouth.
His next three attempts included sacrifices on the high places, and they produced only blessings for Israel. One included the now-famous verses about God’s character:
23:19 God is not a man, so he does not lie. He is not human, so he does not change his mind. Has he ever spoken and failed to act? Has he ever promised and not carried it through?
The intent of the three sets of sacrifices wasn’t to please God, or to cover sin (which were all to be made in the tabernacle anyway). They were Balaam’s attempts to reach God through divination:
24:1 By now Balaam realised that the Lord was determined to bless Israel, so he did not resort to divination as before. Instead, he turned and looked out toward the wilderness …
This brought the final word from God to Balak the Moabite king:
24:17 A star will rise from Jacob; a sceptre will emerge from Israel. It will crush the foreheads of Moab’s people, cracking the skulls of the people of Sheth.