If a student misses a class, there could be one of two reasons. One is being sick and having an absence that is excused. In this case, the student should not be punished. However, if a student ditches, or skips, a class, this should be punished in some way by the teacher, or the school overall. Students should be encouraged to attend classes, or they'll get behind in their schoolwork. This also equips them for the real world, when they'll have to attend a job whether they want to or not.
Class is something that teachers and schools put a lot of money and effort into in order to teach students lessons and about prepare them for the future. If they choose to miss a class then they will learn that they will get punished for it, just like missing work. When you miss work it shows poorly on your character and could lead you to losing your job. If they realize that doing something bad will be bad on their character then they will see that doing what is right is postitive on their life.
As long as students can manage to pass their exams, it doesn't matter to not come to school. Some students come to school just to avoid doing housework or something else. They come to play rather than studying. However, school is not the only place to learn, home is also or even better.
If someone from a poorer family (no offense meant to anyone) need their sons and daughters to make some extra money from selling, say, cakes or bread on the street, then that student may not be able to attend school full-time. He or she might be required at their job during school hours. Also, if the teacher is "bad" (bad meaning uses foul language, or teaches in an inchomprehensible way), then going to school might not even be beneficial to the student.