The answer to this question can be found in Chapter 30 of the book. Briefly, Jim will not agree to "run for it" with the doctor because he has promised Long John Silver that he will not. Jim does not feel that it would be right for him to go back on his word.
Jim feels that he owes it to Silver to keep his word. Earlier, Silver has really stuck his neck out for Jim. He has persuaded the other pirates not to kill Jim when Jim falls into their hands. Not surprisingly, that makes Jim feel like he should play fair with Silver. Before he is allowed to talk to the doctor, Jim has to swear that he won't run away. Because he owes Silver, and because he is an honest person, Jim refuses to go back on his oath.