Bible Notes Online - Numbers 22 - ESV
Commentary

v1-6: Afraid of the arriving Israelites, Balak called for Balaam. Balaam was a well known prophet, who had some 'success'. Balak realised that military might was useless, so he sought 'spiritual' help.

The N.T. warns us against the doctrine of Balaam (Rev 2.14), and the way of Balaam (Jude 11; 2 Pet 2.15). It is with these warnings in mind that we approach ch 22-25; Balaam says many things that are right and true, but the consequences upon Israel were severe, and thus he was guilty.

v7-8: There was a fee for divination, Balak had to pay Balaam for his prophecy. Balaam sought 'divine inspiration.' But he was something of a 'freelance prophet,' and might find his inspiration from any 'god.'

This 'spiritual' battle (chapters 22-24) concerns control (power, authority); Balak wanted Balaam to exercise control on his behalf, as he feared the nation of Israel. Elsewere in scripture, witchcraft and other demonic practices are all ultimately about control; one person, or 'god' seeking to control another person. Similarly, a person might use manipulation to control another. 

v9-19: The Lord God spoke to Balaam. This does not infer any real or prior relationship; Balaam was a false prophet.

The message from God was clear, 'Do not touch my people' (Ps 105.15); His people were set apart and blessed, and He is faithful to His own. He does not reveal His people's sins to unbelievers (23.21).

v20-22: Balaam's way was perverse (or reckless, v32); in spite of his declared loyalty to God, he did not really want to obey God.

v29: Instead of being amazed at the donkey speaking, Balaam argued with it. (Job 42.2).

v32: Balaam's way was "reckless," or 'perverse' before God.

v34: Balaam's lack of spiritual vision, that he did not see the angel, although the donkey did.

v38: Balaam's repeated claim to loyalty to God, but to what god?

v39-41: Balak's offering; a common practice among ancient peoples; not from faith or devotion, but a means to try to get God to do what he wanted.