In his book, Did Jesus Exist?, Bart Ehrman writes:
"...in [Mark 10:17-27], when a rich man asks Jesus how to have eternal life, he tells him to 'keep the commandments.' Is this what early Christians thought, that it was by keeping the Law that a person would inherit eternal life? Quite the contrary, this is a view that the vast majority of Christians rejected. The early Christians maintained that a person had to believe in the death and resurrection of Jesus for eternal life. Some early Christians - an increasingly greater number with the passage of time - argued precisely against the idea that keeping the Law could bring eternal life. If it could, then what as the purpose of Christ and his death? No, it was not the Law but Jesus who could bring salvation. So why is Jesus portrayed in this passage as saying that salvation comes to those who keep the Law? Because that is something he actually said." (p.309-310)
So Ehrman believes that Mark 10:17-27 is something that Jesus actually said. Here it is in its entirety:
17 As Jesus started on his way, a man ran up to him and fell on his knees before him. “Good teacher,” he asked, “what must I do to inherit eternal life?”
18 “Why do you call me good?” Jesus answered. “No one is good—except God alone. 19 You know the commandments: ‘You shall not murder, you shall not commit adultery, you shall not steal, you shall not give false testimony, you shall not defraud, honor your father and mother.’”
20 “Teacher,” he declared, “all these I have kept since I was a boy.”
21 Jesus looked at him and loved him. “One thing you lack,” he said. “Go, sell everything you have and give to the poor, and you will have treasure in heaven. Then come, follow me.”
22 At this the man’s face fell. He went away sad, because he had great wealth.
23 Jesus looked around and said to his disciples, “How hard it is for the rich to enter the kingdom of God!”
24 The disciples were amazed at his words. But Jesus said again, “Children, how hard it is to enter the kingdom of God! 25 It is easier for a camel to go through the eye of a needle than for someone who is rich to enter the kingdom of God.”
26 The disciples were even more amazed, and said to each other, “Who then can be saved?”
27 Jesus looked at them and said, “With man this is impossible, but not with God; all things are possible with God.”
The first thing to notice is that Jesus lists the second half of the ten commandments: the half that refer to how we are to treat other people. He has not listed the first half of the ten commandments: the half that refer to how we are to relate to God, such as remembering that He brought us out of bondage in Egypt; not having any other gods before Him; not making any graven images; not taking His name in vain; and keeping the Sabbath.
I wonder if Ehrman has ever noticed this. If so, I wonder if he ever wondered why Jesus skips the first half of the ten commandments and only lists the second half. I've always thought that the rest of the story makes it clear why Jesus did so. After the rich man says that he has kept the second half of the commandments, Jesus tells him that he still lacks one thing: sell all his possessions, give them to the poor, and then he will have treasure in heaven. Then come and follow Jesus. Jesus is replacing the first half of the commandments (which are about how we are to relate to God) with himself. Jesus says that he is to be the most important thing in our life. We are to forsake all and follow him. If one thinks about it, this is a very shocking thing to say. Jesus is placing himself in the position of God.
If we understand the story this way, it is clear why the early Christians wouldn't find it to be incongruent with what they believed to be the way to eternal life - faith in Jesus. I think if Ehrman understood this to be the lesson of the story he might change his mind and decide there was no longer any reason to think it contained the actual words of Jesus. But then, it becomes clear that Ehrman's criterion for deciding what was and what was not historically reliable regarding Jesus depends more upon his preconceived notions of who Jesus was. For Ehrman believes that Jesus did not regard himself as anything more than just another human being. Ehrman doesn't believe that Jesus regarded himself as in anyway being divine. So anything that hints that Jesus might have regarded himself in that way simply could not be historically accurate.
But why should we think that Ehrman has the correct view of who Jesus thought that he was? Because Ehrman is a scholar? But there are many Christian scholars who disagree with his view of Jesus. Because Ehrman is a secular scholar? Well, yes he is. But is his secularism shaping his view of who Jesus was? The fact that he will accept the above story as historical if it fits his view of Jesus, but (probably) reject it as historical if it doesn't, suggests that perhaps his secularism is distorting his work as a professional scholar.