Compulsory education ensures that all students nationwide are exposed to the basic knowledge required to live in society. Reference.com states that making some schooling required aims to teach children to read and write well enough to understand the laws of the nation. It also teaches basic arithmetic and allows for written communication. Basic knowledge prepares children for the workforce in later life and makes procuring employment a more manageable goal.
There are also disadvantages to forcing children into education that may not necessarily suit the needs of every individual. Reference.com explains that forcing special needs children to attend a school may put undo strain on the family unit.
While it may be beneficial to attempt education with all students, it may not always be successful. A system that requires attendance may work against students who are adversarial to it. This puts the teachers and students willing to learn in a situation where attempting to educate an unwilling pupil lowers the efficacy of the learning environment for all. Such problem children can make other children less likely to cooperate, which ultimately sabotages the entire enterprise.
The strain on society of enforcing compulsory education must also be considered. Maintaining societal mechanisms necessary to ensure compliance requires no small amount of resources.