Schools are preparing children for adulthood by having a uniform code. Very few jobs in the working world allow employees to rock up to work wearing whatever they like. Most offices and workplaces have a strict dress code, often requiring suits and ties or business attire. Even informal jobs like delivery drivers, cashiers, and gym instructors usually have a uniform of some kind.
Getting children into the habit of wearing a uniform to school every morning is preparing them for the working world, where they will most likely be expected to put on a uniform each day.