Children's books tend to switch between believable life lessons and make-believe. Their characters appear very real and very much like someone you might know. The point of children's literature is to offer entertainment and at times a lesson learned. Matilda does both in a way not entirely obvious to an adult eye.
Matilda could be any one of us. Your next door neighbor, your best friend, or just yourself as a child. She's a quiet little girl who is attentive to her parents and school work, but unfortunately has to face some harsh realities. Her parents don't particularly care for her and she usually has to fend for herself. For children this could be a way to see their parents aren't quite as bad as they think, or it could be a reminder of how their parents could care more.
Either way, Matilda is a good character for children to bond with because she does well in school and is nice to those around her. The only downside is that she seeks revenge on her parents and The Trunchbull for the way they mistreated her. On one hand, it's wonderful that Matilda learns to stand up for herself; on the other, one might worry this isn't a good lesson for children. It might not be appreciated if children are found gluing hats to their parents' heads or dying their hair.
The story does have a happy ending filled with hope. Matilda might not be particularly loved by her parents, but she is loved by her friends and teacher. Matilda's parents drive off, leaving her teacher to care for her.
With the magic of Matilda's powers and the feeling that "the good guys always win" this is a happy book for children and adults alike.