So here's a concrete example of the types of problems existencebox is highlighting:
My sister was laid off from her employer of 8 years 3 months after her first child was born. She was a top performer, and they'd been throwing raises and bonuses at her before she got pregnant. Over the same year or so (there were 3-4 rounds of layoffs), every single pregnant woman or mother with kids under 2 that she knew at the company was also laid off.
I mention this story, and people ask me "Is that even legal?"
And my response is "Of course it's not, but if you've got a 3 month old newborn at home, have just been laid off, and are trying to conserve cash so you don't go bankrupt before getting another job (which, BTW, you will never get if you sue your former employer), are you really going to sue them? Where will you find the money? Where will you find the lawyer? Where will you find the time?"
And then even if you do, they are going to trot out a multimillion-$ defense team who will argue that they laid off 40% of the company, they sold off a business division, the price of oil was down 2/3 from its peak, and all of the layoffs were necessary for the survival of the company. All of which might or might not be true. Look at just a few women's story and it's pretty clear they're breaking the law, but factor in macroeconomic concerns and you can muddy in the waters just enough that they might win.
That's the problem. "It's illegal" does not automatically mean that you can't get away with it. In fact, if you're wealthy and pick the right targets, you can get away with a damn lot of things that are illegal.