While there are several important themes in Tom Sawyer, one of the most important might be personal freedom. Tom spends much of the book trying to escape societal convention, and pushing back against authority whenever and wherever he can. While he is not as committed to the free life as is his friend Huckleberry Finn, Tom is committed to a sort of civil disobedience. He often refuses to follow societal convention simply because a person in authority told him to, and Tom doesn't like to be told what to do.
"Come up here. Now, sir, why are you late again, as usual?"
Tom was about to take refuge in a lie, when he saw two long tails of yellow hair hanging down a back that he recognized by the electric sympathy of love; and by that form was the only vacant place on the girls' side of the school-house. He instantly said:
"I stopped to talk with Huckleberry Finn!"
The master's pulse stood still, and he stared helplessly. The buzz of study ceased. The pupils wondered if this foolhardy boy had lost his mind.
(Twain, The Adventures of Tom Sawyer, gutenberg.org)
Here, Tom leverages what he knows of the standard punishment for late arrivals so he will be sent over to sit by Becky Thatcher. At their age, the boys look at girls as inferior, and to be sent to sit with the girls is a form of punishment. Tom, however, is starting to feel the stirrings of adolescence, and so instead of lying and receiving a lesser form of punishment, he deliberately tells the truth so as to be punished more severely. This would seem strange, except that it is a deliberate maneuver; Tom wants to sit with the girls, and so by telling the truth, he gets what he wants even as the school teacher believes him to be soundly punished. At the time, school beatings were commonplace, so Tom only had to endure pain to which he was already accustomed. By accepting this punishment, Tom gets what he wants, and subverts the authority of the classroom and the teacher.