There is SOME justification for, say, disallowing loose/drapey or very skimpy clothing in school if, for example, you are in a science lab or something. You wouldn't want some poor girl's headscarf catching fire any more than you would want the sleeves of her peasant blouse to catch fire. Or some kid's hair. Or some kid's beard. And you wouldn't want them accidentally spilling something dangerous in their lap when they're wearing shorts.
Dress codes of some sort aren't a bad thing if they simply establish easy-to-follow rules like 'no underwear as outerwear, no swimwear, no asscheeks hanging out, no drugs or booze or profanity on your clothing'. But they always seem to unfairly target girls and obsess over what they wear. As if girls don't have enough problems with way too much focus being on how they dress. My high school had a rule that no cleavage could ever be shown at any time under any circumstance--which is fine if we're talking about boob-bearing shirts, but they meant that ANY visible line/separation between boobs could not be seen EVER, which for big-chested girls means you basically have to wear a turtleneck because your cleavage comes up to your chin.