This thread prompted me to do some research on virginity - which, as you say, has been a staple of most societies for at least 2 millenium. I was especially interested to read up on the Vestals - those powerful women of Rome who guarded the temple of Vesta. I’ve visited the remnents of that temple in the Roman Forum. Admirable women, who, if “I, Claudius” is to be believed, also guarded the wills of the Emperors.
Virginity was also believed (and perhaps rightly so) to be excellent for fertility. Fertility and the cult of virginity were very big in the ancient world.