I think the primary function of mass schooling is to warehouse kids somewhere off the streets and out of the workplace, avoiding having to adapt adult spaces to kids being around. There's a secondary function as a meaningless token mill, for use in pseudo meritocracy. And a tertiary function, much underfunded, of education.