Meeting Huck on the road, Tom already knows that Jim has been set free in Miss Watson's will. However, there is no way that Huck could know that, so in Huck's mind, Jim is still a slave and still subject to punishment by society if Huck steals him from slavery. Tom, seeing the opportunity for an "adventure," decides to help in the theft:
"What! Why, Jim is--"
He stopped and went to studying. I says:
"I know what you'll say. You'll say it's dirty, low-down business; but what if it is? I'm low down; and I'm a-going to steal him, and I want you keep mum and not let on. Will you?"
His eye lit up, and he says:
"I'll HELP you steal him!"
(Twain, The Adventures of Huckleberry Finn, gutenberg.org)
Tom knows that there won't be any real consequences for stealing Jim because Jim is no longer subject to slavery laws. Because of this, Tom has the perfect chance to have a fancy, over-planned adventure of stealing a slave, complete with tunnels, rats, a prison-journal, and mysterious notes with skulls. Tom has no great friendship with Jim, nor does he care about Huck's real affection for the escaped man, and so he uses Huck's feelings as the roots of his game. Tom's plan is childish and unnecessary; he ends up getting shot by accident, which he treats as a great honor. Tom clearly doesn't really care about Jim's status as a free man or about Huck's feelings; he just wants to play.