English Standard Version
Or have you not read in the Law how on the Sabbath the priests in the temple profane the Sabbath and are guiltless?
The priests were allowed and required to work in the temple on the Sabbath:
"'On the Sabbath day, make an offering of two lambs a year old without defect, together with its drink offering and a grain offering of two-tenths of an ephah of the finest flour mixed with olive oil.
Benson explains it this way:
Matthew 12:5-6. Have ye not read in the law, &c. — He does not mean that the words following were to be found in the law, but only that they might read in the law, how the priests were obliged, on the sabbath days, to perform such servile work in the temple as, considered separately from the end of it, would have been a profanation of the sabbath,
I.e., they would have profaned the Sabbath if they were not asked by God.
but really was not so, because it was necessary to the public worship of God, on account of which the sabbath was instituted. If it be asked what servile work the priests performed on the sabbath, the answer is obvious. On that day, as well as on other days, they made up the fires, killed, flayed, and dressed the sacrifices, and performed other pieces of manual labour necessary to the religious service which God had established among them. Nay, besides the continual burnt offering, the priests were obliged, on the sabbaths, to sacrifice two lambs extraordinary, by which their servile work was that day double of what it was on the other days of the week.
The priests were not guilty of breaking the Sabbath as alluded to by Jesus in Matthew 12:5.