The title of the question is:
Are Hosea 6:6 and Matthew 9:13 connected?
Insofar as “connected” means “related, associated (in nature or idea),”1 I would have to answer in the affirmative since Matthew 9:13 appears to be a direct quotation of Hosea 6:6. That Matthew 9:13 is a quotation is further substantiated by the phrase “If you had known what this means” (εἰ δὲ ἐγνώκειτε τί ἐστιν) in Matthew 12:7.
I suppose this leads us to the next question,
Does the Lord Jesus Christ appropriately quote Hosea 6:6?
To answer this, we examine the Book of Hosea.
In Hosea 4:1–2, it is written,
1 Hear the word of Yahveh, O’ children of Israel, for Yahveh has a controversy with the inhabitants of the land, because there is no truth, nor mercy, nor knowledge of God in the land. 2 Cursing,2 and lying, and killing, and stealing, and committing adultery! They break out, and blood touches blood.
א שִׁמְעוּ דְבַר יַהְוֶה בְּנֵי יִשְׂרָאֵל כִּי רִיב לַיהְוֶה עִם יוֹשְׁבֵי הָאָרֶץ כִּי אֵין אֱמֶת וְאֵין חֶסֶד וְאֵין דַּעַת אֱלֹהִים בָּאָרֶץ ב אָלֹה וְכַחֵשׁ וְרָצֹחַ וְגָנֹב וְנָאֹף פָּרָצוּ וְדָמִים בְּדָמִים נָגָעוּ
That there is no truth, nor mercy, nor knowledge of God in the land is evidenced by the presence of cursing, lying, killing, stealing, and committing adultery in the land. These acts are violations of the Torah, the covenant between God and Israel.
Accordingly, in Hosea 6:7–8, it is written,
7 But they as men3 have transgressed [the] covenant. There they dealt treacherously against Me. 8 Gilʿad is a city of workers of iniquity; it is covered with footprints of blood.
Men transgressed the covenant (the Torah) by committing acts of sin, which is the transgression of the Torah.4 These acts included cursing, lying, killing, stealing, and adultery. There was so much violence that the prophet portrays the city as “covered with footprints of blood.”
Such violence also existed during the days of Jesus. Indeed, in the Talmud, the rabbis relate that the cause for the destruction of the second Temple (in 70 A.D.) was שנאת חנםת—“hatred without cause,”5 which the rabbis say the Torah equates in gravity to “idol worship, forbidden sexual relations, and murder.”6
Therefore, the Lord Jesus Christ does quote Hosea 6:6 appropriately. God “desired mercy and not sacrifice.” This does not mean God wants people to be merciful (i.e., show mercy) to Him. Rather, He wants people to be merciful towards one another, by keeping the covenant they made with Him. For example, when the Torah commands people to love one another, and people keep this commandment, then they simultaneously keep the covenant with Yahveh.
For this reason, the Lord Jesus Christ said,7
7 But if you had known what this means, “I desire mercy and not sacrifice,” you would not have condemned the guiltless. NKJV, ©1982
Judging righteously is another means by which people (i.e., the judges) show mercy to others8 while keeping the covenant (i.e., obeying the Torah).
1 Oxford English Dictionary (online), “connected,” 3.
2 i.e., placing people under a curse
3 or, “like Adam”
4 cf. 1 John 3:4
5 Babylonian Talmud, Seder Moʿed, Tractate Yoma, Chapter 1, Folio 9b, Gemara; cf. Jerusalem Talmud, Seder Moʿed, Tractate Yoma, Chapter 1, Halakha 1, Folio 4b, Gemara
6 ibid. (Jerusalem)
7 Matt. 12:7
8 cf. Zec. 7:9