Gentiles are especially forbidden to perform commandments that require the holiness of a Jew, such as writing a scroll of the Torah or a mezuzah or phylacteries (tefillin in Hebrew).
The general rule is that any Jewish mitzvah between man and man, or between man and G-d, which has a reason and a logical benefit for a person or society, is permitted for Gentiles to perform. But this does not apply for any commandment that does not have a logical, natural benefit, but instead is a sign for the Jews (e.g., wearing ritual fringes [tzitzit] or phylacteries, or affixing a mezuzah on a doorpost),65 or is a Godly statute for Jews without reason or benefit understood to a person.
65 Radvaz on Hilhot Melahim, ch. 10 (the Divine Code by Rabbi Moshe Weiner, Ask Noah International, 2018, p 61-62).