For years, Marty was told that Doc Brown was dangerous, a crackpot, a lunatic. So, being a red-blooded American teenage boy, age 13 or 14, he decided to find out just why this guy was so dangerous. Marty snuck into Doc’s lab, and was fascinated by all the cool stuff that was there. When Doc found him there, he was delighted to find that Marty thought he was cool and accepted him for what he was. Both of them were the black sheep in their respective environments. Doc gave Marty a part-time job to help with experiments, tend to the lab, tend to the dog, etc. And that’s the origin of their relationship.