At one point in the novel, when rejected by Becky, Tom seriously considers running away and plans his future career, from running wild with Indians to the honoured life of a soldier. Finally, he settles on being a pirate.
Now his future lay plain before him, and glowing with unimaginable splendour. How his name would fill the world, and make people shudder! How gloriously he would go ploughing the dancing seas, in his long low black racer, the Spirit of the Storm, with his grisly flag flying at the fore! (chapter 8)
As is clear from this quote, the life of a pirate seems to Tom to be an especially daring, free, and glamorous one, affording the ultimate chance for adventure. He yearns for excitement, far away from the respectable stuffiness of his little hometown of St Petersburg.
Later in the story Tom coaxes his close friends Joe Harper and Huck Finn into pretending to be pirates also, as they spend a few glorious wild days on Jackson's Island, far removed from the constraints of civilisation. Jackson's island is one spot where the boys can give their imaginations full rein.