Note the following verses:
- Matt. 12:6: τοῦ ἱεροῦ μεῖζόν ἐστιν ὧδε (“greater than the temple is here”)
- Matt. 12:41: πλεῖον Ἰωνᾶ ὧδε (“greater than Jonah is here”)
- Matt. 12:42 cf. Luke 11:31: πλεῖον Σολομῶντος ὧδε (“greater than Solomon is here”)
The argument is as follows: David was king of Israel and just a man. He, and those who served him, profaned the Sabbath out of necessity and were held blameless. The priests served the earthly Temple (only an “example and shadow of the heavenly”),1 out of duty on the Sabbath, and they, too, were held blameless. How much more blameless are the eternal king of Israel, who is both the true Temple of God2 and God Himself, and those who serve him out of both duty and necessity?
Heinrich Meyer commented,3
v. 6. Jesus had previously (v. 3) argued a majori (from the allowance of the eating of the shewbread for the hungry David) ad minus (to the allowance of the Sabbatical plucking of corn for the hungry disciples), so he proceeded (v. 5) his argument a minori (namely, from the Temple, [how] the Sabbath subordinates to [the Temple’s] priestly performance of sacrifices) ad majus, namely, to his own authority transcending the holiness of the Temple, under which [authority] his disciples may be even less bound to the Sabbath. The key to this argument ad majus is in v. 6, which contains the minor premise of the conclusion: what is allowed for the servants of the Temple, namely, to be active on the Sabbath, must also appertain to the servants of him who is greater than the Temple, i.e. “I am greater than the Temple, thus, etc.” In all the sublimity and truth of his self-awareness, Christ indicates by τοῦ ἱεροῦ μεῖζόν ἐστιν ὧδε his own personality and appearance surpassing the Temple in holiness and dignity, not the Messianic work (Fritsche, de Wette, Baumgarten-Crusius), with which the plucking of corn had nothing to do; nor, also, the well-being of the disciples (Paulus, Kuinoel); nor, finally, the ἔλεος (“mercy”) in v. 7. The neuter μεῖζον is weightier than the masculine.4
V. 6. Hatte Jesus vorher V. 3 f. a majori (von der Erlaubtheit des Schaubrodessens für den hungrigen David) ad minus (auf die Erlaubtheit des sabbathlichen Aehrenraufens für die hungrigen Jünger) gefolgert, so ging V. 5. seine Folgerung a minori (nämlich vom Tempel, dessen priesterlichen Opferverrichtungen der Sabbath weiche) ad majus, nämlich auf seine eigene, die Heiligkeit des Tempels überragende Auctorität, unter welcher seine Jünger um so weniger an den Sabbath gebunden sein könnten. Den Schlüssel zu dieser Folgerung ad majus giebt V. 6., welcher den Untersatz des Schlusses enthält: Was den Dienern des Tempels erlaubt ist, nämlich am Sabbath thätig zu sein, muss auch den Dienern dessen zustehen, der mehr ist als der Tempel; mehr als der Tempel bin ich; also u. s. w. —Mit τοῦ ἱεροῦ μεῖζόν ἐστιν ὧδε bezeichnet Christus aus der ganzen Hoheit und Wahrheit seines Selbstbewusstseins seine eigene an Heiligkeit und Würde den Tempel übertreffende Persönlichkeit und Erscheinung, nicht das Messianische Geschäft (Fritzsche, de Wette, vrgl. B. Crus.), mit welchem das Aehrenraufen nichts zu thun hatte, auch nicht das Wohlsein der Jünger (! Paulus, Kuinoel), noch endlich den ἔλεος V. 7.). Das Neutr. μεῖζον ist gewichtiger als das Mascul.
On the difference in genders between the adjective μεῖζόν (neuter) and its proposed referent Ἰησοῦς Χριστός (masculine), note the following comment from the grammar of August Heinrich Matthiae,5

Does the Lord Jesus Christ being “greater than the Temple” in Matthew 12:6 allude to Haggai 2:9?
Haggai 2:9 could not refer to the Second Temple (which was built in the time of King Darius, and which Herod later refurbished). The Talmud states that there were five things missing from the Second Temple that were originally in the First Temple.6
These five things were different between the First Temple and the Second Temple, and these are: (1) the Ark, the cover, and the khruvim; (2) the fire; (3) the Shekhina; (4) the Holy Spirit; and, (5) the Urim and Tummim.
אלו חמשה דברים שהיו בין מקדש ראשון למקדש שני ואלו הן ארון וכפורת וכרובים אש ושכינה ורוח הקודש ואורים ותומים
According to the Jews, the Shekhina was the dwelling presence of Yahveh that filled the Temple with its glory. For example, in 2 Chronicles 7:2, it is written,
And the priests could not enter the house of the LORD, because the glory of the LORD had filled the LORD’s house. NKJV, ©1982
In his Aramaic targum, Yonatan ben Uzziʾel translated it as,
And the priests could not enter the house of the sanctuary of Yahveh, because the glory of the Shekhina of Yahveh filled the house of the sanctuary of Yahveh.
ולא יכילו כהניא למיעל לבית מקדשא דייי ארום אתמלי איקר שכנתא דייי ית בית מקדשא דייי
Without the Shekhina, how could the Second Temple be more glorious than the First? Of course, the problem is resolved when it is realized that the Messiah, possessing God’s own glory, was the true Temple.
Carl Friedrich Keil discussed how Haggai 2:9 applied to the Lord Jesus Christ in his commentary on Haggai.8
Although we must not ignore the reverence which was paid to Zerubbabel’s Temple on the part of the heathen and heathen princes by the offering of sacrifices and votive offerings as precursors of the promised fulfillment of this house with the riches of the Gentiles, likewise we must not look for the actual fulfillment of our prophecy in this outward glorification of the Jerusalem Temple, even if the same had surpassed the grandeur of Solomon’s Temple. This first occurred with Christ, and then, not in the fact that Jesus visited the Temple and taught in it, and as the incarnate Logos, in whom the כְּבוֹד יהוח [“glory of Yahveh”] which filled Solomon’s Temple dwelt (ἐσκήνωσεν) essentially as the δόξα ὡς μονογενοῦς παρὰ πατρός [“glory as the only-begotten from the Father”], he glorified the stone Temple by his presence; but rather, in this way, by the fact that Christ raised up the true temple of God not built with human hand (John 2:19), i.e., by the fact that he exalted the kingdom of God (shadowed in the temple at Jerusalem) to the truth of its essence.
Aber so wenig wir auch die Verehrung, welche dem Zerubabelschen Tempel vonseiten der Heiden und heidnischen Fürsten durch Darbringung von Opfern und Weihgesehenken gezollt wurde, als Vorstufen der verheißenen Erfüllung dieses Hauses mit den Gütern der Heiden übersehen dürfen, so dürfen wir doch eben so wenig in dieser äußerlichen Verherrlichung des Jerusalemischen Tempels, selbst wenn dieselbe die Herrlichkeit des Salomonischen Tempels übertroffen hätte, die eigentliche Erfüllung unserer Weißagung suchen. Diese trat erst mit Christo ein, und auch dann nicht damit, daß Jesus den Tempel besuchte und lehrend in ihm auftrat, und als der fleischgewordeue Logos, in welchem die den Salomon. Tempel erfüllende כְּבוֹד יְהֹוָח wesenhaft als δόξα ὡς μονογενοῦς παρὰ πατρός wohnte (ἐσκήνωσεν), den steinernen Tempel durch seine Gegenwart verherrlichte, sondern dadurch, daß Christus den wahren, nicht mit Menschenhand gebauten Tempel Gottes aufrichtete (Joh. 2,19), d.h. daß er das in dem Tempel zu Jerusalem abgeschattete Reich Gottes zur Wahrheit seines Wesens erhob.
Footnotes
1 Heb. 8:1
2 John 2:19–21 cf. Rev. 21:22
3 Meyer, p. 283–284
4 cf. John 10:29, NA28: “my Father is greater than all” («ὁ πατήρ μου...πάντων μεῖζόν ἐστιν»), where μεῖζόν, although clearly referring to the masculine antecedent ὁ πατήρ, is neuter.
5 Matthiae, p. 720, §437.4
6 Babylonian Talmud, Seder Moʿed, Tractate Yoma, Gemara, Chapter 1, Folio 21b
7 ואיקר שכינתא דייי איתמלי ית משכנא
8 Keil, p. 512–513
References
Keil, Carl Friedrich. Biblischer Commentar über das alte Testament. Dritter Teil: die prophetischen Bücher. Vierter Band: die zwölf kleinen Propheten. 2nd ed. Leipzig: Dörffling and Franke, 1873.
Matthiae, August Heinrich. A Copious Greek Grammar. 5th ed. Vol. 2. London: Murray, 1832.
Meyer, Heinrich August Wilhelm. Kritisch exegetischer Kommentar über das Neue Testament, Erste Abtheilung, Erste Hälfte, Kritisch exegetisches Handbuch über das Evangelium des Matthäus. 5th ed. Vol. 1, Part 1. Göttingen: Vandenboeck and Ruprecht, 1864.