Yes it's illegal for a kid to not go to school once the kid reaches Kindergarten age which is between 5 years old and 6 years old.
Unless you home school your kid then he or she must legally go to school.
If the kid refuses to go to school you either need to home school them or you need to literally drag the kid to school or you could lose custody of your child and they can even put the parents in jail and fine them for not sending the kid to school.
I've had to carry my son off to kindergarten before and he was literally kicking and screaming and it took me and his day to carry him and he would grab onto the car door and hold on for dear life.
He would also sometimes fake like he had the flu, stomach flu a tummy ache, fever etc.
I once caught him taking the the thermometer in his mouth and putting it under the hot water and then I walked in on him doing it.
But he still had to go to school.
I hated school too but kids legally have to go to school.