Rav Hamnuna, in the Talmud, asserts an exclusive correlation between those who lay tefillin and those who may write not only tefillin but also mezuzot and sifrei Torah. The connection has to do with writing.
The mitzvot of tefillin and mezuzah are derived from Deuteronomy 6:8-9:
פרשת ואתחנן
(ח) וקשרתם לאות על ידך והיו לטטפת בין עיניך:
(ט) וכתבתם על מזוזת ביתך ובשעריך:
You shall bind them as a sign upon your hand, and they shall be as totafot between your eyes. You shall write them upon the doorposts of your house and upon your gates.
A straightforward reading tells us that something is to be written on the doorpost, since the commandment is “ktavtam.” Another instance of the root “ktav” is found in the specific context of the term “sefer,” and rabbinic hermeneutics adduce that a mezuzah is therefore to be written using the same laws as other things described as “sefer” – sifrei Torah and gittin (see Menahot 32b). The juxtaposition of the verses commanding tefillin and mezuzot justifies extension of the requirement that a mezuzah be “written” to tefillin: they too must be “written,” and in general tefillin and mezuzot are to be essentially similar. This is a valid halakhic move; it may seem somewhat illogical, but early rabbinic deduction works like that, and is authoritative.
In this juxtaposition also is the link between binding and writing to which Gittin referred; the mitzvah of binding is inextricably linked to the process of writing. Rosh (to Gittin 4:46), Ran (to Gittin 45, s.v. “Sefer Torah”), and Ritva (ibid) accept this association, treating tefillin and mezuzot as a conceptual unit.
For Rosh, the association with the word “ktav,” “write,” continues to the verse “write this as a memorial in a book” (Ex 17:14). This is taken to refer to the Torah, and so the conditions of manufacture are extended from tefillin and mezuzot to sifrei Torah.
רא”ש מסכת גיטין פרק ד סימן מו
מהך ברייתא דכל שאינו בקשירה אינו בכתיבה היה אומר ר”ת דאין אשה עושה ציצית ואוגדת לולב דמיפסלי בעשייתה כיון דלא מיפקדא ונראה מדפסלינן בריש התכלת (דף מב א) ציצית בעובד כוכבים משום דדרשינן בני ישראל ועשו להם ציצית ולא עובדי כוכבים ש”מ דאשה כשרה ואמרי’ נמי בפ”ק דסוכה (דף ח א) סוכת גנב”ך כשירה ואמרי’ בפרק המוכר את הספינה (דף עד ב) דנפקא בת קלא ואמר להו מאי עבידתייהו בהדי קרטליתא דדביתהו דרבי חנינא בן דוסא היא דעתידה למשדי בה תכילתא לצדיקי לעלמא דאתי דדוקא ס”ת הוא דילפינן מתפילין ומזוזה דכתיבה מכתיבה ילפינן אבל בשאר מצות לא
Rosh on Gittin – perek 4 siman 46
…From rules about tefillin-and-mezuzot we can only deduce rules about sifrei Torah, because they are also written. We cannot make any deductions about other mitzvot.
Ritva and Ran take a different approach, working from the premise that a sefer Torah is more holy than either tefillin or mezuzah, and reasoning that if an individual is not fit, for whatever reason, to write tefillin or mezuzot, kal vaḥomer they are not fit to write a sefer Torah.
[Kal vahomer: we take rules associated with a relatively unimportant concept, and then say that the rules associated with a more important concept must be at least equally stringent, if not more so. That is, since we know that a scribe for tefillin and mezuzot must meet certain standards, it would be absurd to suggest that a still holier object have lower standards. Hence the heretic, the informer, the non-Jew, and so on may not write sifrei Torah on the grounds of their invalidity in the writing of tefillin.]
Thus the Ran:
ר”ן לגיטין כג: ד”ה ספר תורה
…ליתנהו בקשירה ליתנהו נמי בכתיבת תפילין ומזוזות דמשתעי בהו קרא וכל שכן בספר תורה דהא קדיש טפי מינייהו…
Ran, Gittin 23b, s.v. “Sefer Torah”
…One who does not bind also does not write tefillin or mezuzot, since the Torah teaches of these. All the more so for a sefer Torah, since it is more holy than they…
And thus the Ritva:
ריטב”א גיטין מה:
קשרתם…כתבתם – כל שישמו בקשירה ישנו בכתיבה, פירוש שישנו בקשירת תפילין ישנו בכל כתיבה קדושה, וכל שאינו בקשירת תפילין אינו בכתיבה. ותפילין ומזוזה יליף לה הקרא גופיה, דקאי בתפילין ומזוזה, ואפילו אשה דחייבת במזוזה אינה ראויה לכתיבה, ומדאינא בכתיבת תפילין ומזוזה משום דקדישי, הוא הדין בספר תורה דקדישי טפי מנייהו.
Ritva, Gittin 45b
“Bind them…write them” – all who are a part of binding are a part of writing. That is to say, one who is part of binding tefillin is part of writing any holy text, and one who is not part of binding tefillin is not part of writing any holy text. We learn for tefillin and mezuzah directly from the Torah because they are holy, and this is also true of a sefer Torah, since it is holier than they.
One may question the above assertions and deductions, but the fact remains: tefillin are inextricably linked, in halakha, to mezuzot, and the two are together associated with sifrei Torah, in early source and in virtually all subsequent rabbinic discussion. Dissociating them is not a step which can be taken easily.