Numbers 22:12-14 ESV
God said to Balaam, "You shall not go with them. You shall not curse the people, for they are blessed."  So Balaam rose in the morning and said to the princes of Balak, "Go to your own land, for the LORD has refused to let me go with you."  So the princes of Moab rose and went to Balak and said, "Balaam refuses to come with us."
From this point Balaam's attitude is wrong: "The LORD has refused me". Which means: 'I really want to go. I want that money from the Moabites, as a reward for cursing the Israelites, so bad. But God's not letting me have what I want'. This was what was wrong with Balaam: his desires were not aligned with God's. And this was his downfall.
Numbers 22:18-19 ESV
But Balaam answered and said to the servants of Balak, "Though Balak were to give me his house full of silver and gold, I could not go beyond the command of the LORD my God to do less or more.  So you, too, please stay here tonight, that I may know what more the LORD will say to me."
God had already said NO. But Balaam goes back for a second opinion! He is really an inconsistent man. He had just said, "I could not go beyond the commandment of the LORD my God". But he goes and asks God if he can go against God's commandment that He had given him the first time. Balaam sounds pious, but his profession of faith is a lie.
Numbers 22:22-23 ESV
But God's anger was kindled because he went, and the angel of the LORD took his stand in the way as his adversary. Now he was riding on the donkey, and his two servants were with him.  And the donkey saw the angel of the LORD standing in the road, with a drawn sword in his hand. And the donkey turned aside out of the road and went into the field. And Balaam struck the donkey, to turn her into the road.
Balaam was so blinded by a desire for money and earthly glory that his spiritual eyes became blinded, more blind than an animal's:
Numbers 22:24-27 ESV
Then the angel of the LORD stood in a narrow path between the vineyards, with a wall on either side.  And when the donkey saw the angel of the LORD, she pushed against the wall and pressed Balaam's foot against the wall. So he struck her again.  Then the angel of the LORD went ahead and stood in a narrow place, where there was no way to turn either to the right or to the left.  When the donkey saw the angel of the LORD, she lay down under Balaam. And Balaam's anger was kindled, and he struck the donkey with his staff.
The donkey was trying to save Balaam's life. When things don't go well in our lives, and we are stopped along the way by frustrating circumstances, it may be God mercifully trying to stop us from facing His greater judgment. May we take heed, stop, turn around, and go the opposite direction.
Numbers 22:28-30 ESV
Then the LORD opened the mouth of the donkey, and she said to Balaam, "What have I done to you, that you have struck me these three times?"  And Balaam said to the donkey, "Because you have made a fool of me. I wish I had a sword in my hand, for then I would kill you."  And the donkey said to Balaam, "Am I not your donkey, on which you have ridden all your life long to this day? Is it my habit to treat you this way?" And he said, "No."
It is a shameful thing when an ANIMAL is able to think more logically than a human, when a man is lectured by a beast of burden. Thus we see here Balaam's sin had made him sub-human. Indeed, his absolute cruelty and anger towards his donkey in this passage shows that his sin has made him become beast-like.
Numbers 22:31 ESV
Then the LORD opened the eyes of Balaam, and he saw the angel of the LORD standing in the way, with his drawn sword in his hand. And he bowed down and fell on his face.
God opens the donkey's mouth and now opens Balaam's eyes.
Numbers 22:34-35 ESV
Then Balaam said to the angel of the LORD, "I have sinned, for I did not know that you stood in the road against me. Now therefore, if it is evil in your sight, I will turn back."  And the angel of the LORD said to Balaam, "Go with the men, but speak only the word that I tell you." So Balaam went on with the princes of Balak.
The thing is, Balaam ultimately did not obey this commandment. Balaam later advised Moabites to seduce the Israelites into idolatry and prostitution to make them become perverse in God's sight.
Balaam's sin is a miracle of sorts: he witnessed two amazing miracles: a donkey speaking, the angel of the Lord standing with a sword. And yet his heart did not forsake his sin of the love of honour and wealth. This is the evidence that no amount of miracles can change the ways of a person who will not repent of his or her idolatrous loves of their heart:
Prayer: Father God, may our desires be aligned with yours. And if we have heard you saying "NO" once, through your Word, help us to not go back to you for a second opinion. Help us to simply obey your will, with no ifs or buts. May love for money and earthly glory not blind us from spiritual dangers we are in because of our sin. May we take heed your warning when we are, according to your providence, stopped by our circumstances, so that we will genuinely turn from our evil ways. In Jesus' Name we pray. Amen.