In the first paragraph of the Shema, it states, “You shall bind them (i.e. the words of the Torah) upon your arm… And you shall write them on the doorposts of your houses and your gates.” Our Sages reveal that by juxtaposing the commands to bind and to write, the Torah is qualifying who can write tefillin, namely, only one who is included in the act of binding is included in the act of writing! This certainly precludes a gentile from writing the parchments (even if he knew how to), because he is not even obligated in the mitzvah. What about a Jew who chooses not to wear the tefillin himself? He is obligated, but he does not do it - is he included in the act of binding?! It depends: if he has nothing against the mitzvos, or tefillin, in particular, it’s just that he does not fulfill this mitzvah (or perform it properly), out of laziness or convenience, he is still included in the act of binding. However, if he does not perform it out of “spite”, then indeed, he is excluded and is not permitted to write. Furthermore, if a Jew is an ‘apikores’ (i.e. a Jew who denies cardinal principles of faith and belief, including Oral Tradition), not only are his tefillin invalid; in some cases they must be burned!
The exclusion of those who are not “binders” from writing tefillin extends also to the entre process of making the tefillin as well – from the ‘batim’-making, to the stitching etc. However, he may still qualify for some of the preparatory processes, such as tanning the hides for the parchment or ‘batim’. Thus, for example, a non-Jew may be involved in the tanning process, provided that a Jew oversees him, to ensure that they are processed ‘lishmah’, i.e. for the sake of the ‘kedusha’ (holiness) of tefillin, which only a Jew can do.