Jesus gives a three part defense for the action of his disciples: The first is an example, the second is a precept, and the third is an a fortiori argument.
First, he gives an EXAMPLE. David broke the ritual laws it in the OT (1 Sam. 21).
Second, the priests were commanded to do it as a PRECEPT. In the OT, the priests needed to offer a sacrifice on the Sabbath (Num. 28:9-10) and offer the consecrated bread on the Sabbath (Lev. 24). This was work, but it was permitted for God’s purposes.
Third, Jesus uses an A FORTIORI argument to clinch his argument. The Temple was God’s presence in part, but Jesus was God’s presence in full. Therefore, if priests could “break” the Sabbath based on God’s orders in the Temple, then the disciples could “break” them for the greater Temple (v.6).