The rich young ruler with his pride contrasts dramatically with the humble infants in the last pericope.
18:18 The young man believed he could do something to earn eternal life, and he wanted to make sure he had not overlooked it (cf. 10:25). John 3:3-15 shows that eternal life includes life in the messianic kingdom. To obtain eternal life meant to enter the kingdom (John 3:3-5). Luke and Mark both have him using the word "inherit"(Gr. kleronomeso) while Matthew wrote "obtain"(Gr. scho). This difference probably reflects Matthew's use of the young man's original word. Mark and Luke probably used the word "inherit"for their Gentile readers to clarify what was in the rich young ruler's mind. He was talking about getting something that he as a Jew thought that he had a good chance of obtaining because of his ethnic relationship to Abraham.
18:19 Jesus' question accomplished two things. It set the standard for goodness, namely God (cf. v. 11). It also confronted the man with the logical implication of his question (v. 18), namely that Jesus was God. That the man did not believe that Jesus was God seems clear from his response to Him (v. 23).
18:20-21 Jesus returned to the young man's question (v. 18). If he wanted to obtain eternal life by doing something, he would have to keep God's laws. Jesus cited the fifth through the ninth commandments from the Decalogue that deal with a person's responsibilities to his or her fellowman (Exod. 20:12-16). By doing so, He affirmed the authority of the Old Testament. He was also gracious with the man by not referring to the commands about people's responsibilities to God or the command about coveting. The man's response indicated that he had kept the letter of the law (cf. Phil. 3:6).
18:22 Having passed the first test to his satisfaction, Jesus now presented him with the higher hurdle of not coveting, the tenth commandment (cf. Rom. 7:7-8). Jesus' command exposed the man's greed, which is idolatry (Col. 3:5). Thus this man had really violated the first and the tenth commandments. If he would have been willing to give away his possessions, he would have shown that he was repudiating his greed. By following Jesus, he would have shown that he was repudiating his own self-righteousness. These would have been the appropriate fruits of his repentance. Treasure in heaven implies eternal reward (cf. 12:33-34).
18:23 The man's sorrow on hearing Jesus' command was proportionate to his wealth. His unwillingness to part with his riches showed that he valued them more than treasure in heaven. He really wanted material wealth more than eternal life (v. 18).
The other Synoptic evangelists recorded that at this point the young man went away (Matt. 19:22; Mark 10:22).
Jesus' logic is quite clear in this conversation. He reasoned that God alone is perfect (v. 19). Moreover God's standard for obtaining eternal life by good works is perfection (vv. 20-21). Therefore no one can obtain eternal life by good works.