Supply vs Demand.
There are more competent, charismatic individuals available to teach social sciences and arts than there are available to teach STEM.
Let's take my own profession - accounting - which commands reasonably high pay as professors. PhD programs in accounting are not robust. Very few accountants choose to go into academics and teach. The vast majority of my professors were Masters/CPAs with work experience. PhD Professors in accounting at my school currently make between $175,000 and $291,000 per year - and they make up fewer than 25% of the teaching faculty. Going forward into a PhD seems prudent for professors, as stopping at a Masters degree appears to limit them to a ceiling of $100,000, with most making less than $75,000, but most professors don't pursue it because they became professors as a way to downshift.
There are so many opportunities to exit academia at all levels of accounting that lead to practical hands-on jobs. Surprise surprise, but most accountants study accounting to become accountants, not professors. And that's how it is with most STEM degrees.
Taking a look at my Economics professors - all of whom were PhDs (and men - a total sausage fest) - their salaries are all five figures. There's a couple of guys making six figures and they all seem to run a department or special research units. Why? Because the Economics department was a cesspool of "I don't know what to do with my degree, so I guess I'll get some more degrees." There are a lot of Economics PhDs because no one knew what to do with an Econ BA... and then they still didn't know what to do with an Econ Masters Degree. There are few exit opportunities - and certainly not in our geographic area. But salaries aren't depressed because it's female-dominated. Far from it, there are very few women in Economics.
Women tend to gravitate to disciplines that are fun and interesting to study, with programs that let a lot of people in and jobs that people are interested in working. And in the end there are more PhDs than there are jobs for PhDs in those fields and universities get their pick of the litter. They can pick the best person there is among a whole pool of candidates to take their job and that person will accept whatever salary is offered because she doesn't have a ton of options. The accounting department, on the other hand, picks the one moderately engaging PhD who applies for their Tax Professor job and thanks god that they found someone with half a personality. And damn, if a woman with a PhD in Accounting shows up and she's good at teaching, they'll throw $291,000 at her (that's right, the top salary in the department belongs to the only female PhD of accounting at my school - and they sure don't want to lose her, because then they'll have none).
The job placement rate exiting my Masters of Accounting program was 90% BY graduation. 56% of Masters of Economics graduates at my school moved on to PhD programs instead of jobs.
It's not sexism. If you want to make more money, you have to choose fields of study where the demand for candidates is higher than the supply.