Numbers 25
1 While Israel was staying in Shittim, the men began to indulge in sexual immorality with the daughters of Moab
One of them was Cozbi, the daughter of Zur, a tribal chief of a Midianite family. Zimri son of Salu, the leader of a Simeonite family, indulged in sex with her.
Cozbi invited Zimri to her idol worship.
2 [The Moabite daughters] invited them to the sacrifices for their gods. And the people ate and bowed down to these gods. 3So Israel joined in worshiping Baal of Peor, and the anger of the LORD burned against them.
4The Lord said to Moses, “Take all the leaders of these people, kill them and expose them in broad daylight before the Lord, so that the Lord’s fierce anger may turn away from Israel.”
5So Moses said to Israel’s judges, “Each of you must put to death those of your people who have yoked themselves to the Baal of Peor.”
In addition to executions carried out by the judges on these leaders, God started a plague to kill other participants.
6 Then an Israelite man [Zimri] brought into the camp a Midianite woman [Cozbi] right before the eyes of Moses and the whole assembly of Israel while they were weeping at the entrance to the tent of meeting.
Zimri and Cozbi were the key players in this affair of sexual immorality and idol worship due to their respective leaderships in their tribes
7 When Phinehas son of Eleazar, the son of Aaron, the priest, saw this, he left the assembly, took a spear in his hand 8and followed the Israelite into the tent. He drove the spear into both of them, right through the Israelite man and into the woman’s stomach. Then the plague against the Israelites was stopped;
Zimri and Cozbi were representatives of the affair, killing them literally stopped the plague.