From Pope St. John Paul II’s encyclical Veritatis Splendor (1993):
The answer he receives about the commandments does not satisfy the young man, who asks Jesus a further question. “I have kept all these; what do I still lack?” (Mt 19:20). It is not easy to say with a clear conscience “I have kept all these”, if one has any understanding of the real meaning of the demands contained in God’s Law. And yet, even though he is able to make this reply, even though he has followed the moral ideal seriously and generously from childhood, the rich young man knows that he is still far from the goal: before the person of Jesus he realizes that he is still lacking something. It is his awareness of this insufficiency that Jesus addresses in his final answer. Conscious of the young man’s yearning for something greater, which would transcend a legalistic interpretation of the commandments, the Good Teacher invites him to enter upon the path of perfection: “If you wish to be perfect, go, sell your possessions and give the money to the poor, and you will have treasure in heaven; then come, follow me” (Mt 19:21).
Like the earlier part of Jesus’ answer, this part too must be read and interpreted in the context of the whole moral message of the Gospel, and in particular in the context of the Sermon on the Mount, the Beatitudes (cf. Mt 5:3-12), the first of which is precisely the Beatitude of the poor, the “poor in spirit” as Saint Matthew makes clear (Mt 5:3), the humble. In this sense it can be said that the Beatitudes are also relevant to the answer given by Jesus to the young man’s question: “What good must I do to have eternal life?”. Indeed, each of the Beatitudes promises, from a particular viewpoint, that very “good” which opens man up to eternal life, and indeed is eternal life.
The Beatitudes are not specifically concerned with certain particular rules of behaviour. Rather, they speak of basic attitudes and dispositions in life and therefore they do not coincide exactly with the commandments. On the other hand, there is no separation or opposition between the Beatitudes and the commandments: both refer to the good, to eternal life. The Sermon on the Mount begins with the proclamation of the Beatitudes, but also refers to the commandments (cf. Mt 5:20-48). At the same time, the Sermon on the Mount demonstrates the openness of the commandments and their orientation towards the horizon of the perfection proper to the Beatitudes. These latter are above all promises, from which there also indirectly flow normative indications for the moral life. In their originality and profundity they are a sort of self-portrait of Christ, and for this very reason are invitations to discipleship and to communion of life with Christ.26
26Cf. Catechism of the Catholic Church, No. 1717.
— Veritatis Splendor 16