In the absence of the knowledge of Indian sciences, we of course know about the gross body (Sthool Shareer) but in addition, we should understand the subtle body (Sookshma Shareer).
Ayurveda is all about the interplay between the gross body and the subtle body. Our subtle body has three doshas (Tridoshas) namely Vata (air), Pitta (fire), and Kapha (water). These three primary life forces are the bio-energies that make an individual. All these three doshas are linked to menstruation. Menstruation in Ayurveda is regarded as a special occasion for monthly cleansing of the excess doshas.

Every month as the body prepares for pregnancy there’s a build-up of energies during that time. If pregnancy does not occur this accumulated energy from the body is exhausted during menstruation. Of the three doshas. The Vata (air) dosha is mainly responsible for the downward flow of energy.
Women absorb other energies in their environment during this time. This reason is the basis for most of the cultural practices in India like not entering temples, the reason behind this is that in temples the flow of energy is upwards because of the mantras, the offerings, etc while the flow of energies in a menstruating woman is downwards. This upward and downward flow of energies in a woman can lead to serious menstrual health issues. It can also damage her reproductive health.
Keeping this in mind our ancestors made sure this knowledge reaches every single woman in the fastest way possible. The best method was to induce fear that your diety will be offended if you enter a temple as they were looking for a bigger solution of ensuring that women’s menstrual health is not irrevocably altered.
It’s not discrimination, It’s discretion.