Bio major here - the unfortunate thing about evolution is that it pushes what increases survivability and fitness (reproductive success), not what is good or nice. Think of how some bird parents will allow their offspring to kill each other and raise the strongest one. Sometimes natures cruel.
The leading theory is that bleeding and painful periods pushed our ancestors to mate more and reject incompatible mates. If you arent pregnant and you have a partner, it (in nature) may indicate poor mate quality and worsen your survival and fitness as a female. Hence, females with more “encouragement” to mate and find productive mates were selected for