who knows why we have it this way...
The answer is sexism. When women started to enter the workforce there was concern that they would get "overwhelmed", so gendered bathrooms were created to give them a space they could go to that feels like the home.
Can confirm: have no idea if I've ever shared a bathroom with a trans person because I am there to go to the bathroom, not interact with strangers.