Symbolism, Imagery, Allegory
We know what you're thinking. "Aww, come on, Shmoop, you really expect me to believe that there's some kind of deeper meaning in all that imaginary kid's stuff Tom and his friends do? Everybody plays games like that when they're a kid!" Well, it is true that lots of people pretend to be robbers or pirates cowboys when they're kids, but there's more than one way to look at Tom's boyish fantasies.
Look at it this way: you may have pretended to be a robber or a pirate, but did the stuff that you imagined ever begin to come true? We're going to guess, no.
For the most part, Tom dreams of running away and becoming a pirate or a soldier or a robber are fun ways to spend time and escape from his ordinary life. We see him playing games involving these characters and we see him dreaming about them when things aren't going well in real life.
But then Tom's fantasies start playing out in his real life. As it just so happens, his town has attracted a criminal, Injun Joe, who doesn't think twice about murdering or stealing. Now, Twain could have come up with any number of villains for Tom to meddle with, but he chose to create a character that embodies everything that Tom wants to be – gone wrong. He's sort of like a nightmare come true. (You can read more about the Tom-Injun Joe connection in the "Character Roles" section.)
Now all of this talk about wish-fulfillment and fantasy-as-reality wouldn't really hold water if it weren't for…the treasure.