In 12:5, Jesus makes a different point to defend His apostles - "The priests in the temple profane the Sabbath, and are blameless". What Jesus means here is that while it appears the priests violate the Sabbath by their actions, actually they do not. Numbers 28:9,10 commanded offerings to be made on the Sabbath. Therefore, it must be concluded that the work which God commanded the priests to do did not fall under the prohibition to do no work on the Sabbath. Activity in the work of God was both allowed and commanded. Jesus has thus proven that not all "work" performed on the Sabbath is sinful. Jesus' argument here seems to be this: If the priests can work on the Sabbath and be guiltless, why can't My disciples pluck grain on the Sabbath and eat it in order to satisfy their hunger without sinning?
Jesus then referred to Himself and extended the reasoning of the previous verse - "In this place there is One greater than the temple" (Matt. 12:6). He appears to be implying that if the service that the priests offered in the temple justified them working on the Sabbath, how much more does the service of His disciples justify them in their actions! They were justified because their service to Him was more important than priestly service since Jesus Himself was (and is) greater than the temple. It is understood that if the priests had not been serving in the temple, then there would have been no need for them to "work" on the Sabbath. Likewise, if Jesus' disciples hadn't been traveling with Him, they would have provided food for themselves by working during the week and would not have had a need to be in the fields plucking grain on a Saturday as they journeyed.
Jesus rebuked the Pharisees in 12:7 for condemning His innocent disciples and also stated - "I desire mercy and not sacrifice" (Hos. 6:6). They would not have condemned His apostles had they understood Hosea's inspired message. Jesus is teaching here that if a person's attitude is wrong toward others (i.e., an attitude lacking mercy), then God is not pleased with that person regardless of what great sacrifices they may offer Him. Jesus is not teaching that God wants mercy only and no sacrifices (even though His words demand this meaning if interpreted in a strict, literal sense). There are other New Testament examples of Jesus making statements for the sake of emphasis that He did not intend to be interpreted in a strict, literal fashion.
In John 6:27, for instance, Jesus declared - "Do not labor for the food which perishes, but for the food which endures to everlasting life..." A literal interpretation of this passage would lead one to conclude that God does not want us to work for physical food. Of course, this couldn't be further from the truth. If we are able to work yet unwilling, we should not expect to eat (II Thess. 3:10). So, when considering John 6:27 in light of the rest of the Scriptures, it becomes obvious that Jesus' point was to emphasize that eternal life is worth laboring for much more greatly than physical food (though our daily bread is also worth working for). Now, with those thoughts in mind, consider Matthew 12:7 again. I believe the Bible teaches that God wants both mercy and sacrifice from His followers (cf. Matt. 23:23), and Jesus is not contradicting that point here. He is, however, emphasizing that sacrifice, even to the extent of the Pharisees, is worthless without a proper attitude (cf. I Cor. 13:3). The disciples should have received mercy and compassion because they were hungry and serving the Messiah Himself, but instead they received criticism and condemnation unjustly.
This narrative closes with Jesus affirming Himself to be the Lord of the Sabbath (Matt. 12:8). As the lawgiver is greater than the law, so Christ is greater than the Sabbath. He is its ruler or "Lord." Thus, Jesus was perfectly able to know exactly what could be done on the Sabbath without sin. The plucking and eating of grain was certainly lawful, and Jesus established this point here by appealing to His divine authority.
In His next recorded encounter with them, He will prove in general that it is not wrong to do good on the Sabbath, thereby showing that the Pharisees had a much too restricted understanding of what constituted "work."