My understanding is that if a student misses a certain number of days they , the school district, are ineligible for Federal reimbursement for tuition for that student. Follow the money.
Yep, that's the real reason for truancy laws.
Usually the revenuers don't have to contend with an excelling student who simply doesn't come to class.
Once the public figures out that it's the Money for Just Us, the judge's reason becomes obvious.