"But when the Pharisees heard that He had silenced the Sadducees, they gathered together. Then one of them, a lawyer, asked Him a question, testing Him, and saying, 'Teacher, which is the great commandment in the law?' Jesus said to him, 'You shall love the LORD your God with all your heart, with all your soul, and with all your mind.' This is the first and great commandment. And the second is like it: 'You shall love your neighbor as yourself.' On these two commandments hang all the Law and the Prophets" (Matt. 22:34-40).
After learning of their rivals being silenced, the Pharisees decide to try again in their questioning of Jesus. They came to Jesus "testing Him." The one who asked the question was a Pharisee as well as a "lawyer" (i.e., an expert in the law). He was there to test Jesus' knowledge of the law. He appears to be sincere and not malicious (cf. Mark 12:34).
"Teacher, which is the great commandment in the law?" - There had been a long running debate among Jewish rabbis as to which commandment was the most important of them all. Some have declared that the Old Testament contains 613 commandments in all. Thus, since the word of God didn't explicitly state which command was the greatest, there was plenty for men to debate on the issue.
It seems likely that the Pharisees have given up trying to trap Jesus in their dilemmas. Perhaps their hope now is that He will give an answer to the question that they can argue about and thereby attempt to discredit His wisdom before the people. Thus far, Jesus' answers to their questions had left them speechless, an embarrassment that they hoped to change with this inquiry.
"You shall love the Lord your God with all your heart, with all your soul, and with all your mind" (cf. Deut. 6:4,5). The idea here is to love God to the fullest extent of one's abilities; we are to love Him with our entire being. But what does it mean to love God? Jesus clearly declared that those who love Him are those who will obey Him (cf. John 14:15-24; I John 2:4,5; 5:3). Those who claim to love God while refusing to submit to Him in complete obedience are only fooling themselves. If a person does not desire to do God's will above everything else, then he does not truly love God.
"This is the first and great commandment" - This commandment is first in the sense that it is the foundation of the entire law of God; it is great because, in a sense, it includes all other laws.
"You shall love your neighbor as yourself" (cf. Lev. 19:18). God demands that the standard of love we apply to ourselves be no different that the one we use with others. To genuinely love your neighbor is not to have a "special attraction" toward him but rather to sincerely desire what is best for him. This desire is what will prevent you from sinning against your fellow man. It will also motivate you to actively do good to him. In all circumstances, to treat others as you would want (or ought) to be treated is the key (cf. Matt. 7:12).
Let it be observed that the second command is like the first in that it addresses the subject of love. Also, there is a sense in which the first commandment includes the second because all humans are made in God's image and to sin against a fellow human being is to show an imperfect love for God (cf. I John 4:20).
"On these two commandments hang all the Law and the Prophets" - These two commands essentially encompass all of the Old Testament commandments. This is easily seen when one considers the Ten Commandments received by Moses on Mt. Sinai (cf. Exo. 20). The first four of these commandments are summarized by the command to love God with one's entire being, and the last six are summarized by the command to love one's neighbor as himself (cf. Rom. 13:8-10).
The scribe replied in Mark 12:32 - "Well said, Teacher. You have spoken the truth." Jesus' answer here, as always, was so undeniably right that it encouraged this word of praise. The man concluded that to love God to one's fullest capacity and to love one's neighbor as himself "is more than all the whole burnt offerings and sacrifices." For this Pharisee to compliment Jesus and make such a statement as this reveals a great deal about his character. He was apparently a lover of truth and was not prejudiced against Jesus (at least not to the extent that many of his fellow Pharisees were). Also, he evidently was not afraid of arousing the displeasure of the other Pharisees.
"You are not far from the kingdom of God" (Mark 12:34). Jesus acknowledged that the man had answered wisely. One's proximity to the kingdom of God is not a measure of feet or inches but of the preparation and purpose of the heart. No genuine lover of truth is far from God's kingdom. Though it is impossible to know for sure, it seems probable that a man like this, with a good and honest heart, would obey the gospel after he heard it proclaimed on Pentecost or thereafter.