Menstruation is usually thought of as the periodic discharge through the vagina of a bloody secretion containing tissue debris from the shedding of the endometrium from the nonpregnant uterus.

However, as the average frequency of human intercourse, every three days or so, is high enough to make it likely that an ovulation will result in a pregnancy, this continuous sexual activity could also mean that bacteria and viruses can hitch regular free rides deep into the woman's reproductive tract.
One defense against such infection is the plug of mucus at the cervix that blocks sperm from ascending except during two or three fertile days a month. Another natural defense mechanism is menstruation. The hot flow of blood conbined with the change in pH is disastrous for pathogens and it sweeps them away from the sweet environment of the woman's innards.
In the natural environment, most women would experience far fewer menstrual cycles, since they would not cycle while pregnant or lactating, which would be most of time, given the standard of cyclical estrous and birth rates among mammals. Since humans do have sex more frequently, but have fewer offspring, menstruation is an important evolutionary defense mechanism designed to keep the females of the human race healthy.