The man in reference bellow was perfect just he didn't want to leave his possessions and follow Jesus!
We all sin yes but with God all things are possible! he gives us true understanding and that is the ability to turn from sin! And unto man he said, Behold, the fear of the Lord, that is wisdom; and to depart from evil is understanding. Job‬ 28‬:28 KJV
When his disciples heard it, they were exceedingly amazed, saying, Who then can be saved? But Jesus beheld them, and said unto them, With men this is impossible; but with God all things are possible. Then answered Peter and said unto him, Behold, we have forsaken all, and followed thee; what shall we have therefore? And Jesus said unto them, Verily I say unto you, That ye which have followed me, in the regeneration when the Son of man shall sit in the throne of his glory, ye also shall sit upon twelve thrones, judging the twelve tribes of Israel. Matthew‬ 19‬:25-28‬ KJV)
You have an incorrect understanding of the story of the Rich Young Ruler.
The Rich Young Ruler plainly believed that we can earn eternal life by doing good works and keeping the commandments. So he asked Jesus..." what GOOD THING shall I DO to obtain eternal life? So Jesus explained that if he was wanting to obtain eternal life by DOING GOOD THINGS he would have to keep all of the commandments of Moses including not stealing, killing or committing adultery.
Instead of admitting that he had broken the commandments, in his pride, he claimed that he had never broken a single commandment since childhood. So Jesus decided to show Him that he had indeed broken the commandments. So Jesus preceded to show Him that He had broken both the tenth commandment (Thou shalt not covet) as well as the first commandment (You shalt have no other gods before me)
So to show that he was coveteous Jesus said to Him... sell all you have and give to the poor... but the young man wouldn't do it... and so Jesus proved to him that He was a lawbreaker in need of mercy.
Then, to show that he was putting other gods before God Jesus said "come and follow Me". But the young man wouldn't do that either so Jesus proved to him that he was putting other things before the Lord. So that proved that the young man was a lawbreaker in need of mercy.
So at this point the young man should have done what the sinner did in the story of the Pharisee and the tax collector did.... He should have fallen down at Jesus' feet and said... "Lord, have mercy on me, a sinner!" If he would have done that He would have been forgiven and justified.
Instead, he just walked away sadly. Jesus never once explained the gospel to the young man. The young man wasn't ready to hear the gospel. He was so committed to the idea of salvation by his ability to keep the law that he wasn't ready to hear the concept that He was a sinner who needed to look in faith to Jesus for mercy.
Now Peter already was a believer in Jesus. As a result of His Faith he had done many good deeds. And Jesus assured him that believers like him who have done much for Christ will be rewarded with many good things and also, since they are believers, will have eternal life.
This does not teach that we earn salvation by our works. It teaches that once we have faith in Christ and are justified and saved we will then be willing to follow Christ and all believers are rewarded for their works.
Finally, if you look in John 5:24 you will see that the moment we believe in Jesus we already have eternal life and will not ever come into judgment. Jesus says "Most assuredly I say to you, he who hears my word and believes in Him who sent me HAS everlasting life, and SHALL NOT come into judgment but HAS PASSED from death into life."
So first, the moment we stop trusting in our works and simply believe in Jesus to save us we HAVE eternal life. We possess it immediately and SHALL NOT ever be judged. Then, since we believe in Jesus and are already saved... we are willing to follow Him. So when we die we will be rewarded and will continue to have everlasting life.