Jesus drew an analogy from Scripture (cf. 1 Samuel 21:1-9). His point was twofold, first that ceremonial traditions are secondary to divine service. [source][source][source]
What David did was contrary to the Mosaic Law ( Leviticus 24:9), yet Scripture did not condemn him for what he did (cf. 2 Chronicles 30:18-20). What Jesus" disciples did was not contrary to the Mosaic Law, so the Pharisees should not have condemned them for what they did. Why did the Scriptures not condemn David for what he did? They did not because David was serving God. God permitted him to violate the ceremonial law, but not the moral law, without condemnation. In this sense he was above the law. (This may explain why God allowed David to perform some normally priestly functions such as offering sacrifices without rebuke.) Therefore the Son of Man ( Luke 6:5), who is superior to David, had the right to set aside a Pharisaic tradition, not a divine law, in the service of God. [source][source][source]