Have you ever wished you were sick, or for the power to go out so you wouldn’t have to do something? Ever wished that a tire would go flat so you’d have a legitimate excuse to be late? When something “bad” happens and you get out of something you might consider worse, that’s secondary gain. Sometimes you really do feel sick and sometimes you really are. You may not even be consciously causing it, it could be the stress and dread of the event causing you to get or feel sick. It’s not always; but sometimes it’s secondary gain.
This is the same with children. It doesn't have to be conscious; but sometimes it can be.
Sometimes it's difficult to really know if a child doesn't feel well because they don't want to go to school that day, or because they are really sick. Sometimes they have a very good reason not to go to school. Hopefully you have or develop a good enough relationship with your children, and a history of listening without harsh judgement and punishment, so that you can ask questions and find out what's really going on. In some situations you may even need to ask other for input.
While my children were growing up, there was a rule of thumb. If they were sick enough to miss school, then even if they felt better in the afternoon, they needed the extra rest and were not able to do any of the activities they might want to do in the late afternoon or evening. During school, if they were too sick to attend, they probably needed to be in bed resting and not watching TV or playing games.
Two cautionary notes: Sometimes people prefer to stay in bed because they are depressed and sometimes anything is better than going to school because of some significant fear. Neither of these should be dealt with casually. Often times they require additional professional help. Your child's doctor and school, and sometimes even law enforcement may provide the resources you need.