From Pope St. John Paul II’s encyclical Veritatis Splendor (1993):
[That the commandments represent the basic condition for love of neighbor] certainly does not mean that Christ wishes to put the love of neighbour higher than, or even to set it apart from, the love of God. This is evident from his conversation with the teacher of the Law, who asked him a question very much like the one asked by the young man. Jesus refers him to the two commandments of love of God and love of neighbour (cf. Lk 10:25-27), and reminds him that only by observing them will he have eternal life: “Do this, and you will live” (Lk 10:28). Nonetheless it is significant that it is precisely the second of these commandments which arouses the curiosity of the teacher of the Law, who asks him: “And who is my neighbour?” (Lk 10:29). The Teacher replies with the parable of the Good Samaritan, which is critical for fully understanding the commandment of love of neighbour (cf. Lk 10:30-37).
These two commandments, on which “depend all the Law and the Prophets” (Mt 22:40), are profoundly connected and mutually related. Their inseparable unity is attested to by Christ in his words and by his very life: his mission culminates in the Cross of our Redemption (cf. Jn 3:14-15), the sign of his indivisible love for the Father and for humanity (cf. Jn 13:1).
Both the Old and the New Testaments explicitly affirm that without love of neighbour, made concrete in keeping the commandments, genuine love for God is not possible. Saint John makes the point with extraordinary forcefulness: “If anyone says, ‘I love God’, and hates his brother, he is a liar; for he who does not love his brother whom he has seen, cannot love God whom he has not seen” (1 Jn 4:20). The Evangelist echoes the moral preaching of Christ, expressed in a wonderful and unambiguous way in the parable of the Good Samaritan (cf. Lk 10:30-37) and in his words about the final judgment (cf. Mt 25:31-46).
— Veritatis Splendor 14