The reason to stuff everyone in one box is socialization. A group of students subjected to shared experiences will develop community and solidarity easier than every individual student bouncing in their own special way in the system.
It has even been observed that people can bond over a shared meal better than if everyone eats their own different food.
Overall a huge huge part of school is about socializing, with fellow students or against fellow students, obeying and rebelling against teachers, being honest or cheating to copy your homework, the dynamics of bullying and protecting from bullies, snitching on others or lying to protect minor wrongdoers, feeling guilt when you made the wrong decision, feeling proud for the right decision, discovering the difference of rules and morals, of friendship and togetherness and betrayal and loyalty, of acting tough or showing compassion, of romance and heartbreak, etc. So many lessons that aren't taught by teachers explicitly or asked on a test. But these add up to a stable individual later on who can draw from a rich well of experiences for later reference, even in adulthood. You can do a lot of low risk experimentation at that age. If people become atomized, dropped into a class full of almost strangers in each subject, there is no way to develop group dynamics of the above sort. Maybe you can do some of it with your sports team but you spend much less time with them than with a shared class.