Jim ran away because Miss Watson was going to sell him down South.
Huck runs away from his abusive father, and soon runs into an escaped slave. While he lived with Miss Watson, Huck got to know Jim and appreciate him. When Jim told Huck that he had run off, Huck was surprised, but he promised not to tell anyone.
“Well, you see, it 'uz dis way. Ole missus—dat's Miss Watson—she pecks on me all de time, en treats me poorty rough, but she awluz said she wouldn' sell me down to Orleans. But I noticed dey wuz a nigger trader roun' de place considable lately, en I begin to git oneasy. (ch 8)
One of the worst things about being a slave is not having any control over your life, and being sold away from your family.
The question of whether to turn Jim in or not plagues Huck for much of the book. His conscience tells him to, because that is the law. It’s what is societally acceptable. Yet Jim is Huck’s friend, and he is a good person. Huck never does turn him in, and even tries to free him once he gets captured.