Conformity, the theory is that kids will behave better when they all look like each other and can’t single each other out. Which is completely wrong, as we’ll always find ways to separate ourselves from each other.
Schools are full of bad administrators who are poor at managing those they’re responsible for, and a hallmark of bad management is blanket policies, dress codes are an example of this, and dress codes begin a slippery slope of what a student can or can’t do, including hairstyles, extracurricular activities, what they read, and more.