Jesus started out by helping the rich ruler know in his heart, if he was approaching Jesus as God - or just as a good teacher. Then He listed some of the Ten Commandments to reveal that the ruler wasn’t as perfect at keeping all of them, as he thought. And he asked the ruler to choose between his material wealth, and eternal life - demonstrating that we have to be willing to sacrifice our desires, for God's desires--and the rich ruler left disappointed.
Eternal life comes by way of sacrifice. Christ had to sacrifice so much in order that we might be able to have it. And we must follow his example of sacrifice, by denying ourselves and taking up our cross, in order that we might be able to receive eternal life.
We must be willing to suffer the loss of anything and everything for the sake of Christ, otherwise we will ultimately receive the dreaded loss of eternal separation from him.