Balaam taught Balak to tempt Israel into idolatrous and sexual sin.
Balak, king of Moab, hired Balaam to curse Israel. GOD eventually allowed Balaam to visit Balak but only permitted Balaam to speak the words GOD gave him. Instead of cursing Israel, Balaam blessed Israel, prophesying about their future, including the Messiah.
Apparently the love of money eventually got to Balaam. The next thing we see in Scripture is that Balaam persuaded Midian to tempt Israel into sinning, thereby angering GOD and leading GOD to punish Israel.
The historical record says:
1 Now Israel remained in Sattin, and the people were defiled by committing fornication with the daughters of Moab. 2 They invited them to the sacrifices of their idols; and the people ate their sacrifices and worshiped their idols. 3 So Israel consecrated themselves to Baal of Peor; and the Lord was very angry with Israel. 4 Then the Lord said to Moses, “Take all the rulers of the people and make a public example of them for the Lord, that the anger of the Lord’s wrath may be turned away from Israel.” 5 So Moses said to the tribes of Israel, “Each one of you kill any member of his household who was consecrated to Baal of Peor.”
6 Now behold, a man of the children of Israel came and brought his brother to a Midianite woman in the sight of Moses and all the congregation of the children of Israel; and they were weeping at the door of the tabernacle of testimony. 7 Now when Phinehas the son of Eleazar, the son of Aaron the priest, saw this, he rose from among the congregation; and taking a spear in his hand, 8 he went after the man of Israel into the chambers and thrust both of them through, the man of Israel, and the woman through her womb. So the plague was stopped among the children of Israel. 9 But those who died in the plague were twenty-four thousand.
(Numbers 25:1-9 OSB)
After punishing Israel for their sin—and purging the sinners from among the people—GOD turned His vengeance upon Midian. It is at that point, recorded in Numbers 31, where we learn of Balaam's involvement in these affairs:
1 Now the Lord spoke to Moses, saying, 2 “Exact vengeance from the Midianites for the children of Israel. Afterward you shall be added to your people.” 3 So Moses spoke to the people, saying, “Arm some of your men to stand in battle array before the Lord against Midian, to repay vengeance from the Lord on Midian. 4 From all the tribes of Israel you shall send a thousand from each tribe to stand in battle array.”
5 So from the thousands of Israel they counted a thousand from each tribe, twelve thousand armed for the battle line. 6 Then Moses sent them, a thousand from each tribe with their army, and Phinehas the son of Eleazar the priest with the holy vessels and the trumpets for signaling in his hands. 7 So they arrayed themselves in battle against Midian, as the Lord commanded Moses, and they killed every male. 8 They killed the kings of Midian, together with their slain people: Evi, Zur, Rekem, Hur, and Reba, the five kings of Midian. They also killed Balaam the son of Beor with the sword, along with their slain people. 9 They also took as plunder the women of Midian, with their households, their cattle, all their possessions; and they plundered their army. 10 They also set on fire all the cities where they dwelt and all their unwalled villages. 11 They took as well all their booty and spoils from man to cattle. 12 Then they brought the captives, the spoils, and the booty to Moses, to Eleazar the priest, and to all the congregation of the children of Israel, to the camp in the Araboth of Moab by the Jordan, across from Jericho.
13 Then Moses, Eleazar the priest, and all the rulers of the congregation went to meet them outside the camp. 14 But Moses was angry with the overseers of the army, with the captains over thousands and rulers over hundreds, who were coming from the battle line of the war. 15 So Moses said to them, “Why did you take every female alive? 16 For on account of Balaam’s counsel, they were with the sons of Israel and caused them to depart from and despise the Lord’s word in the incident at Peor, when there was a plague among the congregation of the Lord. 17 Now therefore, kill every male among all the little ones, and every woman who slept with a man. 18 But keep alive for yourselves all the young girls who have not slept with a man. 19 But you remain outside the camp seven days, and everyone who killed or touched someone killed, both you and your captives, shall be purified on the third day and the seventh day. 20 Purify every garment, everything made of leather, everything woven of goats’ hair, and everything made of wood.”
(Numbers 31:1-19 OSB)
The judgment upon Midian was severe. But Midian had earned this judgment with their evil, wicked behavior, including long before this recent temptation of Israel. Remember that it was because of the wickedness of the Canaanites that GOD told Israel to destroy all Canaanite nations and purge the land of its sin in the first place.
Finally, Israel's warriors, including their clothes and weapons, needed to be purified.
21 Then Eleazar the priest said to the men in the army who came from the battle lines of the war, “This is the ordinance of the law, which the Lord commanded Moses: 22 Besides the gold, the silver, the brass, the iron, the lead, and the tin, 23 everything that can pass through fire shall be purified; otherwise, it shall be purified with the water of purification. Therefore whatever cannot pass through the fire shall pass through the water. 24 You shall also wash your clothes on the seventh day and be clean, and afterward you may come into the camp.”
25 Again the Lord spoke to Moses, saying, 26 “Take the sum of the spoils of the captives, from man to cattle, you and Eleazar the priest and the rulers of the families in the congregation; 27 and divide the spoils between the warriors who went out into the battle lines and all the congregation. 28 And levy a tribute for the Lord on the men of war who went out to the battle lines, one soul of every five hundred men, and of the cattle, the oxen, the sheep, and the goats. 29 Then you shall take their tribute and give it to Eleazar the priest as a firstfruits to the Lord. 30 But from the children of Israel’s half you shall take one of every fifty of the men, the oxen, the sheep, the donkeys, and from all the cattle, and give them to the Levites who keep charge in the tabernacle of the Lord.” 31 So Moses and Eleazar the priest did as the Lord commanded Moses.
32 The booty remaining from the plunder which the men of war took was six hundred seventy-five thousand sheep, 33 seventy-two thousand oxen, 34 sixty-one thousand donkeys, 35 and thirty-two thousand human souls, that is, the women who had not slept with a man. 36 And the half, the portion for those who had gone out to war, was in number three hundred thirty-seven thousand five hundred sheep; 37 and the Lord’s tribute of the sheep was six hundred seventy-five. 38 The oxen were thirty-six thousand, of which the Lord’s tribute was seventy-two. 39 The donkeys were thirty thousand five hundred, of which the Lord’s tribute was sixty-one. 40 The human souls were sixteen thousand, of which the Lord’s tribute was thirty-two souls. 41 So Moses gave the Lord’s tribute, God’s choice portion, to Eleazar the priest, as the Lord commanded Moses. 42 Then from the children of Israel’s half, which Moses divided from the men of war— 43 that is, the half belonging to the congregation, was three hundred thirty-seven thousand five hundred sheep, 44 thirty-six thousand oxen, 45 thirty thousand five hundred donkeys, 46 and sixteen thousand human souls— 47 and from the children of Israel’s half Moses took one of every fifty, from men to cattle, and gave them to the Levites who kept charge of the tabernacle of the Lord, in the manner the Lord commanded Moses.
48 Then all those established in positions as commanders in the army, the captains over thousands and rulers over hundreds, came near to Moses; 49 and they said to Moses, “Your servants took the sum of the men of war with us, and not a man of us is missing. 50 Therefore we have brought a gift to the Lord, what every man found of articles of gold: bracelets, rings, armlets, and hair-clasps, to make atonement for us before the Lord.” 51 So Moses and Eleazar the priest took the gold from them, every crafted article. 52 So every choice portion of gold which they dedicated to the Lord, from the captains over thousands and rulers over hundreds, was sixteen thousand seven hundred fifty shekels. 53 (Now each of the men of war had taken plunder for himself.) 54 So Moses and Eleazar the priest took the gold from the captains over thousands and rulers over hundreds and brought these into the tabernacle of testimony, as a memorial for the children of Israel before the Lord.
(Numbers 31:21-54 OSB)
For such a relatively minor role in history, Balaam's actions and character would be held up for all future generations of students of Scripture as an example of how not to live. Balaam is referenced in this way three times in the New Testament writings:
9 ... the Lord knows how to rescue the godly from trials and to hold the unrighteous for punishment on the day of judgment. 10 This is especially true of those who follow the corrupt desire of the flesh and despise authority.
Bold and arrogant, they are not afraid to heap abuse on celestial beings; 11 yet even angels, although they are stronger and more powerful, do not heap abuse on such beings when bringing judgment on them from the Lord. 12 But these people blaspheme in matters they do not understand. They are like unreasoning animals, creatures of instinct, born only to be caught and destroyed, and like animals they too will perish.
13 They will be paid back with harm for the harm they have done. Their idea of pleasure is to carouse in broad daylight. They are blots and blemishes, reveling in their pleasures while they feast with you. 14 With eyes full of adultery, they never stop sinning; they seduce the unstable; they are experts in greed—an accursed brood! 15 They have left the straight way and wandered off to follow the way of Balaam son of Bezer, who loved the wages of wickedness. 16 But he was rebuked for his wrongdoing by a donkey—an animal without speech—who spoke with a human voice and restrained the prophet’s madness.
(2 Peter 2:10-16 NIV)
8 In the very same way, on the strength of their dreams these ungodly people pollute their own bodies, reject authority and heap abuse on celestial beings. 9 But even the archangel Michael, when he was disputing with the devil about the body of Moses, did not himself dare to condemn him for slander but said, “The Lord rebuke you!” 10 Yet these people slander whatever they do not understand, and the very things they do understand by instinct—as irrational animals do—will destroy them.
11 Woe to them! They have taken the way of Cain; they have rushed for profit into Balaam’s error; they have been destroyed in Korah’s rebellion.
(Jude 8-11 NIV)
12 “To the angel of the church in Pergamum write:
These are the words of him who has the sharp, double-edged sword. 13 I know where you live—where Satan has his throne. Yet you remain true to my name. You did not renounce your faith in me, not even in the days of Antipas, my faithful witness, who was put to death in your city—where Satan lives.
14 Nevertheless, I have a few things against you: There are some among you who hold to the teaching of Balaam, who taught Balak to entice the Israelites to sin so that they ate food sacrificed to idols and committed sexual immorality. 15 Likewise, you also have those who hold to the teaching of the Nicolaitans. 16 Repent therefore! Otherwise, I will soon come to you and will fight against them with the sword of my mouth.
17 Whoever has ears, let them hear what the Spirit says to the churches. To the one who is victorious, I will give some of the hidden manna. I will also give that person a white stone with a new name written on it, known only to the one who receives it.
(Revelation 2:12-17 NIV)