Thanks to the other answer for pointing me in the right direction with some references. It seems that two biologists in the early 1990s had a back-and-forth over this topic in The Quarterly Review of Biology.1,2
A statement of the problem:
The function of menstruation is a central enigma of mammalian, and especially primate, reproductive physiology. Each cycle the uterus builds a glandular epithelium with a high secretory capacity and an elaborate microvasculature, only to reabsorb or void it with the menses if implantation does not oc-cur. Why does the endometrium not maintain a steady state of readiness for implantation by the blastocyst? What is the selective advantage of cyclical regeneration and regression?1
In 1993, Margie Profet hypothesized that menstruation is primarily advantageous as a defense against pathogens transported by sperm. During mammalian insemination, she stated, bacteria from the male and female genitalia cling to sperm tails and are transported to the uterus. Menstruation, triggered by the abrupt constriction (causing necrosis of endometrial lining) followed by dilation (causing shedding of said necrotic tissue), forces loose not only the endometrial lining but sperm-borne pathogens contained therein. In addition to shedding the uterine tissue harboring these bacteria, menstruation delivers immune cells to the uterine cavity, triggered by the mechanical pressure exerted via the shedding of endometrial lining.
In this 50 page (!) article, Profet also points out that other mammals with covert menstruation take advantage of some of these same benefits, as the immunological stimulation includes phagocytosis of pathogens by cells that may be expelled in cervical/vaginal mucous. Further, proestrous bleeding (i.e. that preceding ovulation, 180 degrees off from the human cycle), which occurs in some mammals (domestic dog, coyote, etc), seems to serve a similar function.
If not eliminated prior to estrus, these tenacious pathogens might otherwise attach to incoming sperm during estrus and ascend the oviducts.
As to why humans and other primates are subject to overt bleeding in contrast to other mammals, she lays out a theoretical argument that selection pressure to menstruate should increase with decreasing per-cycle “fecundability” (the probability of pregnancy) because copulation not followed by bleeding risks infection. In contrast to, e.g., mice (98% fecundability), humans have some of the lowest fecundability rates, primarily due to “concealed” ovulation which de-couples copulation and ovulation. (Contrast this to most mammals whose females have a defined estrous period during which they are receptive to male sexual advances; the data for the existence of such a period in humans are controversial, and sexual behavior is driven primarily by “higher” social, environmental, and cognitive cues.)
A different view1
In response/objection to this paper, Beverly Strassman in the same journal published an article outlining an alternative hypothesis about the potential adaptive value of menstruation. She proposed a hypothesis based on energy conservation:
[T]he uterine endometrium is shed/resorbed whenever implantation fails because cyclical regression and renewal is energetically less costly than maintaining the endometrium in the metabolically active state required for implantation.
Her research determined that, in its regressed state (i.e. s/p endometrial shedding), oxygen consumption in the endometrial tissue is markedly declined, nearly sevenfold. Although this would seem to be a trivial component of whole-body metabolism, she argues otherwise:
Metabolic rate is at least 7% lower, on average, during the follicular phase than during the luteal phase in women, which signifies an estimated energy savings of 53 MJ over four cycles, or nearly six days worth of food.
Her argument shares with Profer’s the implication that mammals with lower fecundability are more likely to menstruate. In those with high probability of pregnancy at every cycle, the energetic benefits of ridding the body of the need to support endometrial lining (relevant only in the absence of pregnancy), are decreased. Her hypothesis also predicts the larger volume of menstrual shedding in humans and chimps in contrast to other mammals related to the increased uterine size relative to the female body (a ratio that is largely determined by the especially large head of the human fetus).
As noted in the comments, only primates have overt menstrual bleeding. The adaptive benefits have been variously explained, and it is probable that there is more than one operative explanatory model. Whatever the small decrement in survivalship incurred by the intermittent and uncontrolled depositing of blood in the wild, it is apparently outweighed in these species by the processes described above.
References and Notes
1. Strassmann, Beverly I. The Evolution of Endometrial Cycles and Menstruation The Quarterly Review of Biology, June 1996; Vol. 71, No. 2 pp 181-220.
2. Profet, Margie. Menstruation as a Defense Against Pathogens Transported by Sperm. The Quarterly Review of Biology, Sept 1993; Vol. 68, No. 3 pp. 335-386.
Note: Your comparison to urine and feces is an interesting one. Perhaps a vaginal sphincter would be a good idea…..were it not for men and babies….