Tom Sawyer is Huck’s good friend, introduced in a previous book by Mark Twain, The Adventures of Tom Sawyer. Huck calls him a "well-brought up" boy, and we see that he is also well read, imaginative, and incurably mischievous. At the beginning of the story, Huck and Tom play together, Huck expressing a desire to be more like Tom. Tom is not physically present for most of the tale, but Huck refers to him frequently, wishing he could make up as good a story as Tom could, or come up with a better plan.
Therefore, despite his absence, Tom is an important character. Some of the bigger issues become evident when Tom comes back onto the scene at the end of the novel. Supposedly, he’s the "well-brought up" kid with good principles and a solid conscience, but he allows Jim to suffer as a prisoner without disclosing that the man is free. Sure, he "compensates" him at the end, but the fact that he uses Jim as a toy is a reinforcement of the idea of Jim as property and somehow sub-human. Notice also that Huck is appalled at a "well-brought up" boy’s willingness to steal a slave, an act he obviously still considers despicable. It looks like some lessons haven’t quite been learned throughout the course of the novel.
Still, we have to remember that Tom, like Huck, is a young boy, and just as liable to pranks, flights of fancy, and playful games. In fact, if the Widow’s religion is the church and Jim’s is superstition, Tom’s "religion" is his literature. He repeatedly tries to emulate the books he’s read, plotting his plans around how things should be according to history or fiction. He presents to Huck yet another system of rules, another insistence of how things ought to be. This perhaps even satirizes other systems of laws – like religion, or superstition, or even the actual laws of the country (such as slavery).
The idea is, when a person or group of people is so focused on obeying the rules and fails to question those rules and their outcomes, they often miss the forest for the trees. Tom himself fails to see the big picture at the end of the novel – the fact that Jim is a person separated from his family and forced to live in mock-prison for mere purposes of entertainment. And he fails to do so because he’s so caught up in his own system of rules based on the books he has read. It’s the same thing with everyone else in the novel. Silas Phelps, for example, is so caught up in obeying the rules surrounding slavery (that is, returning Jim to his "rightful owners") that he too misses the fact that Jim is a person, not property.