The Pharisees probably enjoyed the embarrassment of their enemies, the Sadducees. One showed respect for the Lord (Mark 12:28), and asked a question of his own: "Teacher, which is the greatest commandment in the Law (v. 36)?”
We have every reason to believe He asked the question in sincerity and with a humble heart. This was not a new question, for the scribes had been debating it for centuries.
They had documented 613 commandments in the Law, 248 positive and 365 negative. No person could ever hope to know and fully obey all of these commandments.
To make it easier, the experts divided the commandments into "heavy" (important) and "light" (unimportant). A person could major on the "heavy commandments," and not worry about the trivial ones.
The problem behind this approach is obvious: You need only break one law, heavy or light, to be guilty before God.
"For whoever keeps the whole law and yet stumbles at just one point is guilty of breaking all of it (James 2:10).”
Jesus quoted the "Shema (Deut 6:4),” a statement of faith that was recited daily by every orthodox Jew. The word Shema comes from Hebrew, meaning "to hear."
The greatest commandment is to love God with all that we are and have — heart, soul, mind, strength, possessions, and service. To love God is not to "have good feelings about Him," for true love involves the will as well as the heart. Where there is love, there will be service and obedience.
But, love for God cannot be separated from love for one's neighbor, so Jesus also quoted Lev 19:18, and put it on the same level as the Shema. All of the Law and the Prophets hang on both of these commandments.
We might add that the teachings of the Epistles in the New Testament agree with this statement. If a man really loves God, he must also love his brother and his neighbor (1 John 3:10-18; 4:7-21).
If we have a right relationship with God, we will have no problems with His commandments. Love is the basis for obedience. In fact, all of the Law is summed up in love (Rom 13:8-10). If we love God, we will love our neighbor.
Matthew 22:34-40: “Hearing that Jesus had silenced the Sadducees, the Pharisees got together. One of them, an expert in the law, tested him with this question: ‘Teacher, which is the greatest commandment in the Law?’ Jesus replied.: ‘Love the Lord your God with all your heart and with all your soul and with all your mind.’ This is the first and greatest commandment. And the second is like it: 'Love your neighbor as yourself.’ All the Law and the Prophets hang on these two commandments."
Let's look at verse 40. "All the Law and the Prophets hang on these two commandments." Jesus went beyond what they asked. He seems to want to show the importance of these commandments as much as He can. He has said that the commandment to love God is greatest. He said the commandment to love your neighbor as yourself is "like it."
Verse 39: "The second is like it." But, Jesus doesn't stop there. He wants us to know how important these two commandments are.
He wants us to spend more than a moment on these things. He adds, "All the Law and the Prophets hang on these two commandments." They are the two commandments on which everything else in the Bible depends. "All the Law and the Prophets hang on these two commandments."
Then, in Matthew 7:12, He says, “So in everything, do to others what you would have them do to you, for this sums up the Law and the Prophets.”
Notice that again Jesus refers to the Law and the Prophets like He did in Matthew 22:40. He says, if you do to others what you would have them do to you, then "this sums up the Law and the Prophets."
In Matthew 22:40, He said, "All the Law and the Prophets hang on these two commandments.” Notice this shows that the Golden Rule depends on what went before — on our relationship to God as our Father who loves us and answers our prayers (Matthew 7:9–12).
Loving others is the visible expression, the practical demonstration, and the fulfillment of what the Old Testament is about.
There is a sense in which the second commandment — to love your neighbor — is the visible goal of the whole Word of God. It's not as though loving God is not here, or that loving God is less important.
Rather, loving God is made visible, sacrificially loving others. I think that’s why the second commandment stands by itself when the New Testament says love fulfills the law.
But, let's go back to our text in Matthew 22:37–40. Here Jesus mentions both the love for God and love for neighbor, and He clearly says, "All the Law and the Prophets hang on these two commandments.”
 Here, He does not say that these two commandments "fulfill" the Law and the Prophets, or that they "are" the Law and the Prophets. He says the Law and the Prophets hang on these two commandments.
Now, He says here that the Law and the Prophets hang, literally, "hang" like a stone around the neck, or a snake on the hand, or a man on a cross, on love.
The Law and the Prophets are hanging on — depending on — something, namely, God's passion that this world be a world of love for God and love to each other. God's word for us is that we take with tremendous seriousness this love.
He is saying that all of scripture, all of his plans for history, hang on these two great purposes: that He be loved with all our heart, and that we love each other as we love ourselves.