The Lord Jesus Christ referred to this scripture twice as recorded in the gospels.
On the first occasion, His message seems to be: associate with the sin sick to bring them healing and exhort those, who consider themselves well and in no need of a doctor, that they need healing, too.
And as Jesus reclined at table in the house, behold, many tax collectors and sinners came and were reclining with Jesus and his disciples. And when the Pharisees saw this, they said to his disciples, “Why does your teacher eat with tax collectors and sinners?” But when he heard it, he said, “Those who are well have no need of a physician, but those who are sick. Go and learn what this means, ‘I desire mercy, and not sacrifice.’ For I came not to call the righteous, but sinners.” Matthew 9:10-13 English Standard Version (ESV)
On the second occasion, He urged those who considered themselves righteous to obey the substance and not just the form of God’s commandments.
Or have you not read in the Law how on the Sabbath the priests in the temple profane the Sabbath and are guiltless? I tell you, something greater than the temple is here. And if you had known what this means, ‘I desire mercy, and not sacrifice,’ you would not have condemned the guiltless. For the Son of Man is lord of the Sabbath.” Matthew 12:5-8 (ESV)
Clearly, these folks thought themselves better than those around them.
But to what scripture (because the New Testament was not yet written) was the Lord referring? He quoted Hosea 6:6, but verses six and seven complete a thought.
For I desire steadfast love and not sacrifice, the knowledge of God rather than burnt offerings.
But like Adam they transgressed the covenant; there they dealt faithlessly with me.
Hosea 6:6-7 (ESV)
Textual notes indicate the term steadfast love is rendered mercy in the Septuagint (Greek translation of the Old Testament).
John Calvin comments on verse six:
It is a remarkable passage; the Son of God has twice quoted it. The Pharisees reproached him for his intercourse with men of bad and abandoned life, and he said to them in Matthew 9, ‘Mercy I desire, and not sacrifice.’ He shows, by this defense, that God is not worshipped by external ceremonies, but when men forgive and bear with one another, and are not above measure rigid. [emphasis added]
Again, in the Matthew 12, when the Pharisees blamed the disciples for gathering ears of corn, he said ‘But rather go and learn what this is, Mercy I desire, and not sacrifice.’ Inasmuch as they were so severe against his disciples, Christ shows that those who make holiness to consist in ceremonies are foolish worshipers of God; and that they also blamed their brethren without a cause, and made a crime of what was not in itself sinful, and what could be easily defended by any wise and calm expounder.
Calvin adds concerning verse seven:
God then subjoins a complaint, — But they like men have transgressed the covenant; there have they dealt treacherously against me. Here God shows that the Israelites boasted in vain of their sacrifices and of all the pomps of their external worship, for God did not regard these external things, but only wished to exercise the faithful in spiritual worship.
Then the import of the whole is this, “My design was, when I appointed the sacrifices and the whole legal worship, to lead you so to myself, that there might be nothing carnal or earthly in your sacrificing; but ye have corrupted the whole law; you have been perverse interpreters; for sacrifices have been nothing else among you but mockery as if it were a satisfaction to me to have an ox or a ram killed. You have then transgressed my covenant; and it is nothing that the people say to me, that they have diligently performed the outward ceremonies, for such a worship is not in the least valued by me.”
We can (and must) replace Calvin’s reference to ‘Israelites who boast in vain’ with the ‘unbelieving church of that age,’ for such they were. And we have these same with us today. It’s not as if they are unaware of the substance of proper worship, it’s just less costly (in the here and now) to practice merely the form of it.
At least two of these folks asked the Lord, “Which commandment is the most important of all?” He answered:
“You shall love the Lord your God with all your heart and with all your soul and with all your strength and with all your mind, and your neighbor as yourself.”
On another occasion He asked one of these folks how they understood the scriptures in a nutshell and they gave the same answer. To this one, the Lord said, “You have answered correctly; do this, and you will live.”
But, as we are prone to do, let us not go beyond what the scriptures say. The best example that comes to mind of mercy correctly applied is that demonstrated by the Lord.

The Woman taken in Adultery. 1644, Rembrandt (1606 – 1669), Public Domain
Here’s the entire story from the source:
Early in the morning he came again to the temple. All the people came to him, and he sat down and taught them. The scribes and the Pharisees brought a woman who had been caught in adultery, and placing her in the midst they said to him, “Teacher, this woman has been caught in the act of adultery. Now in the Law Moses commanded us to stone such women. So what do you say?” This they said to test him, that they might have some charge to bring against him.
Jesus bent down and wrote with his finger on the ground. And as they continued to ask him, he stood up and said to them, “Let him who is without sin among you be the first to throw a stone at her.” And once more he bent down and wrote on the ground.
But when they heard it, they went away one by one, beginning with the older ones, and Jesus was left alone with the woman standing before him. Jesus stood up and said to her, “Woman, where are they? Has no one condemned you?” She said, “No one, Lord.” And Jesus said, “Neither do I condemn you; go, and from now on sin no more.”
So there we have it. When someone is repentant from the heart (and surely she was), the Lord says:
“Neither do I condemn you; go, and from now on sin no more.”
Go and do likewise.