The 23,000 refers to the worship of the gods of Moab and the sexual immorality between some Israelite men and the the daughters of Moab. This is known as the rebellion of Baal of Peor at which 24,000 died by the plague (Numbers 25:9).
As noted here it is possible to see Paul’s 23,000 as a simple understatement and as such is not literally wrong.
Baal Peor was one of the events during the Exodus which Paul sees as an example:
6 Now these things took place as examples for us, that we might not desire evil as they did. 7 Do not be idolaters as some of them were; as it is written, “The people sat down to eat and drink and rose up to play.” 8 We must not indulge in sexual immorality as some of them did, and twenty-three thousand fell in a single day. 9 We must not put Christ to the test, as some of them did and were destroyed by serpents, 10 nor grumble, as some of them did and were destroyed by the Destroyer. 11 Now these things happened to them as an example, but they were written down for our instruction... (1 Corinthians 10) [ESV]
When approached as an example for the church, it is possible to understand why Paul understated the total and, in doing so was being more precise.
In the event of Baal of Peor, people died in different ways:
4 And the LORD said to Moses, “Take all the chiefs of the people and hang them in the sun before the LORD, that the fierce anger of the LORD may turn away from Israel.” 5 And Moses said to the judges of Israel, “Each of you kill those of his men who have yoked themselves to Baal of Peor.” ... 7 When Phinehas the son of Eleazar, son of Aaron the priest, saw it, he rose and left the congregation and took a spear in his hand 8 and went after the man of Israel into the chamber and pierced both of them, the man of Israel and the woman through her belly. Thus the plague on the people of Israel was stopped. (Numbers 25)
The “plague” was stopped after the leaders were hung and Phinehas killed the man and the Midianite woman. The total includes those who were hung, the two Phinehas killed, and those who died by some other means.
The "plague" is מַגֵּפָה which is elsewhere translated as "slaughter:"
The messenger replied, “Israel has fled before the Philistines, and there has also been a great slaughter (מַגֵּפָה) among the troops; your two sons also, Hophni and Phinehas, are dead, and the ark of God has been captured.” (1 Samuel 4:17 NRSV)
In using this event as an example the total who died was 24,000. That is "the slaughter" which is made up of three groups: those who died by hanging, two who died by the spear, and everyone else. Paul says 23,000 πίπτω, literally they "fell:"
We must not indulge in sexual immorality as some of them did, and twenty-three thousand fell (πίπτω) in a single day. (1 Corinthians 10:8)
Normally someone who dies, falls. However, Jesus, the head of the church, died and did not fall. He was hanging at the time of His death, just as were the leaders who sinned at Baal of Peor.
The events at Baal of Peor become an example when the Church is the "everyone else" who died, then 23,000 who "fell" becomes a purposeful understatement of the total (which may actually be correct if the number of those who were hung totaled 998). Paul understands the significance of the LORD having the Israelite leaders hung in the sun before the LORD.
The "understated" total draws attention to the reality the head of the Church died while hanging on the cross. Like those leaders at Baal Peor, Jesus was hung in the sun in order to turn away the anger of the LORD from the all who were yoked to sin.