The entire time that Tom and Huck were devising all sorts of ridiculous "escape" plans to help Jim get out of the shed that he was being held prisoner in, Tom was keeping a secret about Jim:
"Old Miss Watson died two months ago, and she was ashamed she ever was going to sell him down the river, and said so; and she set him free in her will."
So, Jim never even needed to be held prisoner; Tom could've gone to his aunt and uncle and told them that Jim was a free man. But, in order to fulfill his fantasies of adventure that he got from the books he read, Tom makes Jim his own personal prisoner. He says he did it for "the adventure of it."
Jim's reaction comes after Tom gave him forty bucks for his trouble. He is super pleased and happy, and ties his good luck back to superstitions, to the signs that he had seen that he was going to be rich someday. This fits Jim's personality because throughout the entire book he didn't ever really hold grudges, even when Huck played some pretty nasty pranks on him. And, Jim is probably the most superstitious character in the book, tying everything that happened back to some sign of good or bad luck. Huck, true to his tendency to want to know the hows and whys of things, questions Tom in detail about why in the world he had done what he did when Jim was free. He wanted answers; he wanted something to go ponder over, so that he could draw his own conclusions about it, just like he had done about many things in the story-prayer, slavery, Jim's friendship, and his eternal salvation. So Huck just asks the logical questions, which is what he tends to do throughout the entire book.