Jim Hawkins doesn't exactly start out in rags, but he's not a wealthy kid. His parents own an inn, but his father passes away in the first chapters of the novel. His mother is clearly concerned about money, or else she would probably be less intent on getting what Billy Bones owes from his sea chest while the sailor's dead body is still lying on the floor. Once a treasure map falls into Jim's hands, how is he supposed to resist the call to riches and adventure beyond his wildest dreams?
When Jim first leaves the Admiral Benbow Inn to travel to Bristol, he is excited (and a little nervous) about his trip. He is really taken with this fellow Long John Silver, who seems so kindly and courageous and strong. What could possibly go wrong on a sea voyage with a guy like Silver looking out for him?
So all that stuff about Long John Silver being honorable and dedicated to Jim's best interests? Not so much. Jim overhears Long John Silver explaining his plot to wait until the Hispaniola reaches Treasure Island before murdering Jim's friends and making off with Captain Flint's riches. Once Jim realizes that the crew of the Hispaniola is a pirate crew under the leadership of Long John Silver, his treasure hunt becomes a quiet war against the mutineers on board the ship.
Jim's independence is an odd thing: he doesn't seem to be particularly ambitious or anything, but he's incredibly curious. It's Jim's curiosity that drives him away from his friends and toward several key discoveries that help win the battle against the pirates. The first time Jim wanders away, he slips ashore with the first group of pirates. It's on this trip that Jim finds Ben Gunn, the marooned sailor who makes a pact with Doctor Livesey and helps defeat the pirates. On Jim's second trip away, he leaves the fort just after their first battle and winds up taking control of the Hispaniola, beaching it on the north end of the island and becoming Long John Silver's hostage. Jim's willingness to take matters into his own hands winds up saving Doctor Livesey, Squire Trelawney, and Captain Smollett from death at the hands of the pirates.
In a rags-to-riches story, the obvious conclusion is when the main character finds his riches. Obviously, Jim does get a portion of the treasure buried on Treasure Island – if he didn't, this book would be a heck of a lot less satisfying. Once Doctor Livesey comes to rescue Jim and Long John Silver from the remaining pirates in Chapter 33, it turns out that poor, lowly Ben Gunn is the one who first discovered the treasure. And Ben is willing to give the treasure over to Doctor Livesey in exchange for passage off the island and a thousand pounds. So Ben gets his reward, and Doctor Livesey, Squire Trelawney, Abraham Gray, and Jim all take their shares of the treasure.