Cozbi (Hebrew: כָּזְבִּי) was the Midianite wife or courtesan of Zimri, son of Salu, a predominant Simeonite. She was the daughter of Zur, a Midianite chief.
While the Israelites were in Shittim during their time in the wilderness, the Israelites mingled with the women of Moab and were led astray. The Israelites adopted the Moabite's idolatrous ways; they made sacrifices to and prayed to Moabite idols, including the Baal of Peor.
This displeased God, and God commanded Moses to order the leaders of the tribes of Israel to execute those who participated in the idolatrous activities.
While God's command was being done, Zimri paraded Cozbi in front of his relatives, Moses, and those gathered. Zimri and Cozbi then entered a tent and began engaging in sexual intercourse.
This filled Phinehas with righteous passion. Phinehas took a spear and slew Zimri and Cozbi.
Phinehas' actions pleased God, and the plague upon the Israelites stopped. God then formed a covenant with Phinehas and promised everlasting priesthood to Phinehas and his descendants.
God then commanded Moses to make war on the Midianites for trying to deceive and seduce the the Israelites:
Provoke hostilities with the Midianites and attack them, for they harass you with their tricks, the tricks with which they have deceived you in the matter [of the Baal] of Peor, and in the matter of Cozbi, the daughter of the leader of Midian, their sister, who was killed on the day of the plague because [of the Baal] of Peor.— Numbers 25:17–25:18 (AMP)
Moses did as God commanded and led the Israelites in war against the Midianites. They slew every Midianite male, including Cozbi's father Zur, and burned down the Midianite cites. The Israelites took the Midianite women and children captive. Moses then commanded the Israelites to massacred every Midianites who was not a maiden.
Have you let all the women live? Look, these [are the women who] caused the Israelites, by the counsel of Balaam, to trespass against the Lord in the matter of Peor, and so a plague came among the congregation of the Lord. Now therefore, kill every male among the children, and kill every woman who is not a virgin. But all the young girls who have not known a man intimately, keep alive for yourselves [to marry].— Numbers 31:15–31:18 (AMP)
The Israelites did as commanded. Thirty-two thousand Midianite maidens were spared and distributed among the Israelites as spoils of war: 15,968 went to the warriors who participated in the campaign, 16,000 went to non-combatants, and 32 went to the priesthood.