One rich man who thought righteousness, or living eternally in the kingdom of God, was achieved through obedience to the Ten Commandments asked... Jesus what he needed to do to gain eternal life (Luke 18:18).
Jesus, knowing his heart, told him to keep the commandments of God.
The man replied he had kept the commandments since he was a child.
Then Jesus told him to go sell all he had, give to the poor, and follow him, then he would have eternal life.
Jesus' disciples asked him how could anyone gain eternal life if this man could not, since this man had obeyed the law from childhood.
Jesus replied, “What is impossible with men is possible with God”.
It is impossible for us to save ourselves through obedience to the law.
We can only be saved by grace through faith.
This was the point Jesus was making.
The man believed he could save himself through obedience to the Ten Commandments.
So Jesus held the Ten Commandments in front of him as a mirror to show him his sinful heart.
Jesus showed him, through the law, that he actually had not obeyed the law since childhood.
He had actually broken the first two commandments by putting money above God which was idolatry and loving money more than people.
Rather than walking away sad, had the man cried out to Jesus, “Have mercy upon me, a sinner”, he would have walked away justified before God.
Yet the man had no concept of his sin.
Instead, just like the Pharisees, he boasted in his religious activity and his morality, having no awareness of his need for grace (Luke 18:18-27).
He had so much pride that even the law could not convince him he was a sinner in need of grace.
From my book, The Story of Grace (page 83).