Except there is no law prohibiting a woman being cast as a male character, but there are laws prohibiting discrimination against this cancelation on the basis of the lead being female.
If you truly believe they're doing it for preventative legal reasons, why would they just open themselves up to a guaranteed lawsuit instead of following a spirit of law that doesn't even apply to theater?