“One came – This was a young man, Matthew 19:20. He was a ruler (Luke); probably a ruler in a synagogue, or of the great council of the nation; a place to which he was chosen on account of his unblemished character and promising talents. He came running (Mark); evincing great earnestness and anxiety, He fell upon his knees (Mark); not to worship him, but to pay the customary respectful salutation; exhibiting the highest regard for Jesus as an extraordinary religious teacher.

Good Master – The word “good” here means, doubtless, most excellent; referring not so much to the moral character of Jesus as to his character as a religious teacher. It was probably a title which the Jews were in the habit of applying to their religious teachers. The word “Master” here means teacher.

What good thing shall I do? – He had attempted to keep all the commandments. He had been taught by his Jewish teachers that people were to be saved by doing something – that is, by their works; and he supposed that this was to be the way under every system of religion. He had lived externally a blameless life, but yet he was not at peace: he was anxious, and he came to ascertain what, in the view of Jesus, was to be done, that his righteousness might be complete. To “have eternal life” means to be saved. The happiness of heaven is called “life,” in opposition to the pains of hell, called “death,” or an eternal dying, Revelation 2:2; Revelation 20:14. The one is real life, answering the purposes of living – living to the honor of God and in eternal happiness; the other is a failure of the great ends of existence – prolonged, eternal suffering, of which temporal death is but the feeble image.

Matthew 19:17

And he said unto him, Why callest thou me good? there is none good but one, that is, God: but if thou wilt enter into life, keep the commandments.

Why callest thou me good? – Why do you give to me a title that belongs only to God? You suppose me to be only a man, yet you give me an appellation that belongs only to God.

It is improper to use titles in this manner. As you Jews use them they are unmeaning; and though the title may apply to me, yet, you did not intend to use it in the sense in which it is proper, as denoting infinite perfection or divinity; but you intended to use it as a complimentary or a flattering title, applied to me as if I were a mere man – a title which belongs only to God. The intentions, the habit of using mere titles, and applying as a compliment terms belonging only to God, is wrong. Christ did not intend here to disclaim divinity, or to say anything about his own character, but simply to reprove the intention and habit of the young man – a most severe reproof of a foolish habit of compliment and flattery, and seeking pompous titles.

Keep the commandments – That is, do what God has commanded. He in the next verses informs him what he meant by the commandments. Jesus said this, doubtless, to try him, and to convince him that he had by no means kept the commandments, and that in supposing he had he was altogether deceived. The young man thought he had kept them, and was relying on them for salvation. It was of great importance, therefore, to convince him that he was, after all, a sinner. Christ did not mean to say that any man would be saved by the works of the law, for the Bible teaches plainly that such will not be the case, Romans 3:20, Romans 3:28; Romans 4:6; Galatians 2:16; Ephesians 2:9; 2 Timothy 1:9. At the same time, however, it is true that if a man perfectly complied with the requirements of the law he would be saved, for there would be no reason why he should be condemned. Jesus, therefore, since he saw he was depending on his works, told him that if he would enter into life that is, into heaven – he must keep the commandments; if he was depending on them he must keep them perfectly, and if this was done he would be saved. The reasons why Christ gave him this direction were, probably:

1. because it was his duty to keep them.

2. because the young man depended on them, and he ought to understand what was required if he did – that they should be kept perfectly, or that they were not kept at all.

3. because he wanted to test him, to show him that he did not keep them, and thus to show him his need of a Saviour.”

-Albert Barnes

Link:  http://biblehub.com/commentaries/barnes/matthew/19.htm