There's a very compelling societal interest in having children receive a basic education though. We make kids get shots, require them to learn to drive to get a license, etc. for the same reason.
There's no compelling societal interest in brainwashing kids to claim to support a government (since even making them recite the Pledge hardly makes them more reliable citizens).
Public schooling often doesn't provide a basic education, though. The graduating illiteracy rates, lack of any retained historical knowledge ("is Britain a state? or "isn't Toronto in the US?") the inability to do basic arithmatic without a calaculator, etc.
It also doesn't teach anything close to critical thinking, problem solving, questioning fundamentals, or anything close to an exposure to career domains.
Also, the shots are at a parents discretion, even if peer pressure is applied. The choice to get a drivers license is inevitably on the child (you can't force them to take the test). Public education is compulsory by gunpoint (ie, imprisonment of parents who withhold their children from the public school system or homeschooled exams, though there are so many exceptions it is silly).
There's no compelling societal interest in brainwashing kids to claim to support a government (since even making them recite the Pledge hardly makes them more reliable citizens).