Balaam prophesies four times of Israel's blessing, each time more intense than before. The Spirit comes on Him and He sees Jesus, the coming, ruling Star of David.
Israel falls into sexual sin and idolatry, seduced by the women of Moab.
Phinehas, the son of Eleazar the priest, kills two sinning people, and God commends him for it.
How this is about Jesus
24:17 is clearly Messianic. Not only will Israel rule over Moab, but this happens in a person, a Him.
John 8 is a great foil for how Jesus deals with those caught in the act of adultery. We are called to no less vigilance in purity, but civil consequences are different in ancient Israel and now.
Sins this may reveal, or application
23:21 says God has seen no wrong in Israel, after all the complaining and plagues in the whole book of Numbers! This is a declaration of justification apart from works, of forgiveness from sin.
Balaam obeys God and the Spirit comes on him, and he speaks God's words, yet he Has some part in their sin in chapter 25 (see Rev 2:14). Those given wisdom or speaking ability are not immune from sin themselves, and may lead God's people astray.