There is an oral tradition from Moshe Rabbeinu, a "halacha lemoshe misinai," which teaches that on each side of the tefillin shel rosh, there is a letter "shin." On the right side, there is a standard shin, with three legs, while on the left side, the shin has four legs.
There are numerous reasons given for this practice. Some explain that the three and four-legged "shins" remind us of the three avot and four imahot. The Ben Ish Hai notes that the gemara (Berachot 6a) teaches that the tefillin shel rosh is a source of strength (oz) for the Jewish people, as the verse says, "Then all the peoples of the earth will see that the name of the Lord is called upon you, and they will fear you" (Devarim 26:10). He explains that the gematria of the two letter "shins" on the tefillin shel rosh is six hundred. If we include the extra "vav," i.e., the extra leg, the gematria then equals six hundred and six. As the non-Jews were given the seven Noachide laws, the Jewish people were commanded to perform an additional six hundred and six mitzvot. The Ben Ish Hai writes that when the non-Jews see all of these extra mitzvot "they will fear you."
It should be noted that according to the Beit Yosef, the base of the "shin" is a point, and each of the three legs is a different letter, i.e., the right leg is a "vav," the middle leg looks like a "yud," and the left-most leg looks like a "zayin." Our custom, however, is to write the "shin" with a flat base and three "vavs."
Summary: The halacha lemoshe misinai teaches that the tefillin shel rosh have a shin on each side, a three-legged shin, and a four-legged shin. The commentaries offer numerous explanations for this practice.