All the other bluster about tradition and standards or whatever else is all just covering fire to exclusionary policy. Whether that be race based, gender based, class based or otherwise, it's a basis for excluding or removing those outside your group who can't or won't bend to your requirements.
The one and only exception I know of to this is safety dress codes, like loose long hair or garments around certain machinery that could catch those. The rest can go to hell.