The lesson of the rich young ruler. He did not understand the sinfulness of man in need of the Savior. He addressed Jesus as the man as good. Jesus cited all of the Law regarding man to others less the commandment of "thou shall not covet." The purpose was the teaching that by the keeping of the Law no one can be justified. The young man left on his own.
The young man leaves because he is attempting to be justified by the law and Jesus, as Jesus always does, showed that no one is justified by the law. Even though the man had done much to keep the law, he still fell short of justification. Thus he left in sadness.
Humans have always been justified by faith alone. That faith, given to them by God, does the work God ordained them to do.
The reason why Cornelius is given the vision and God brings Peter is precisely because Cornelius had God-given faith to believe under the Abrahamic Covenant, yet he had not heard that the New Covenant had been established for all humanity to receive by God's grace alone.
Cornelius was one of the transitional person's who lived under the Abrahamic Covenant and bridged into the New Covenant.