While the Hebrews camped at Shittim, they began to “whore” with the Moabite women, who invited them to their churches, where the Hebrew men started worshiping Baal. God got pissed and told Moses that cheaters needed to die and in the meantime, It’d send a plague to punish everyone. So Moses told all the tribal leaders to root out and execute everyone who had been worshiping Baal. As this was going on and everyone was mourning the dead, the Hebrew Zimri of the Simeonites married/bought Cozbi, daughter of a Midianite chief (like, you know, Moses’s wife), and this pissed people off so much that Phinehas, son of Eleazar the high priest, took a spear and killed them both while they were consummating the marriage. This made God incredibly happy. Not only was God appeased so that It ended the plague, but it also decided that It liked Phinehas’s zeal so much that It made him and his descendants perpetual priests.
24,000 people perished in this incident.
God was also like, hey, you guys need to make war on the Midianites since they seduced you.