Numbers 25 shows that Israel's greatest danger was not an enemy's curse but its own sin. While Israel stayed in Shittim, Israel joined in sin and false worship with the people of Moab (25:1-3), who invited them to the sacrifices of their gods. The people ate and bowed down. Israel joined himself to Baal Peor, and Yahweh's anger burned against Israel. Numbers 31:16 and Revelation 2:14 reveal that this temptation came through Balaam's advice.
God commanded judgment on those who had joined themselves to Baal Peor. As the faithful wept at the door of the Tent of Meeting, Zimri, a leader from Simeon, brazenly brought Cozbi, a Midianite princess, into the camp in the sight of Moses and all the congregation. Phinehas son of Eleazar rose up and acted to execute God's judgment, and the plague was stopped. Those who died by the plague were twenty-four thousand.
God declared that Phinehas had turned His wrath away because he was jealous with God's jealousy. He gave Phinehas His covenant of peace, the covenant of an everlasting priesthood, because he made atonement for the children of Israel. Psalm 106:30-31 remembers this. God's jealousy is not petty. It is the right love of a faithful husband for His people. Jesus, our great High Priest, turned away God's wrath not by taking life, but by giving His own (Romans 5:9).