In this week's Parsha, as Bnai Yisrael leave Mitzrayim after witnessing many miraculous events, they are commanded to remember those events of Yetzias Mitzrayim by wearing some kind of sign or reminder with a written record of them on their arms and on their heads (שמות י"ג:ט, ועיין בפירוש רש"י שם בד"ה על). This commandment is repeated in the last Posuk of the Parsha (שם פסוק ט"ז); the reference, of course, is to the Mitzvah of Tefillin. The Mishnah in Menachos (דף כ"ח.) refers to four Parshiyos, or sections of the Torah, which are found in the Tefillin because, as noted by Rashi (שם בד"ה ד'), they each contain references to this Mitzvah; the Gemara (שם דף ל"ד:) then identifies these four Parshiyos, which include two that appear in this week's Parsha, namely, קדש (שמות י"ג:א'-י') and והיה כי יביאך (שם פסוקים י"א-ט"ז), and two that appear later in the Torah, namely, שמע (דברים ו:ד'-ט') and והיה אם שמוע (שם י"א:י"ג-כ"א). The Rambam (פרק א' מהל' תפילין הלכה א') and the Shulchan Aruch (אורח חיים סימן ל"ב סעיף א') both codify that these are indeed the four Parshiyos of Tefillin.
As mentioned above, the Torah requires that one wear these Parshiyos on one's arm as well as on one's head; the Tefillin thus really consist of two separate units, the one for the arm being the Tefillah (which is the singular form of the word Tefillin) Shel Yad, and the one for the head being the Tefillah Shel Rosh. One major difference between the Shel Yad and the Shel Rosh relates to the writing of the above four Parshiyos; the Gemara (שם) states that for the Shel Yad, these Parshiyos are written on one piece of parchment, while for the Shel Rosh, they are written on four separate pieces of parchment. The Rambam (פרק ב' שם הלכה א') and the Shulchan Aruch (שם סעיף ב') rule accordingly; the Mishnah Berurah (שם ס"ק ו') explains the reasons behind this, adding, in the name of the Rambam (שם), that even for the Shel Yad, each of the four Parshiyos should be written in a separate column.
The precise order in which these four Parshiyos must appear on the parchment of the Shel Yad, as well as the order in which the four separate pieces of parchment are to be placed into the Shel Rosh, each in its own compartment, as stated by the Shulchan Aruch (שם סעיף מ"ה), is the subject of a major Halachic dispute. Rashi, commenting on the aforementioned Gemara in Menachos (שם בד"ה והקורא), writes that the Parshiyos should appear in the same order in which they appear in the Torah, as listed above, that is, with the Parsha of קדש coming first, followed by the Parsha of והיה כי יביאך, then the Parsha of שמע, and finally, the Parsha of שמועוהיה אם. This means that on the parchment of the Shel Yad, the four Parshiyos must appear in this order, while in the Shel Rosh, the Parshiyos are to be found in their compartments in that order starting on the left side of the person wearing the Tefillin, so that someone looking at the Tefillin Shel Rosh would see the Parshiyos in that order when reading (as one normally does in Hebrew) from right to left.
Rabbeinu Tam, however, is quoted in Tosafos (שם בד"ה והקורא, ועיין בשיטה מקובצת שם אות כ"א) as disagreeing; he holds that the Parsha of והיה אם שמוע follows the Parsha of והיה כי יביאך, and is thus in the third slot, while the Parsha of שמע is in the fourth slot. This means that the Parsha of שמע is the last Parsha on the parchment of the Shel Yad, and that it is in the compartment of the Shel Rosh which is to the farthest right of the wearer and to the farthest left of the on-looker. As pointed out in Tosafos (שם), Rav Hai Gaon concurred with this latter view, noting that in this order, the two "הויות," that is, the two Parshiyos which start with the word "והיה" (והיה כי יביאך andוהיה אם שמוע ) are juxtaposed. Tefillin whose Parshiyos appear in the order of their appearance in the Torah are popularly known as Rashi Tefillin, although many other important authorities agree to this position as well, while Tefillin whose Parshiyos appear in the other order, with והיה אם שמוע preceding שמע, are popularly known as Rabbeinu Tam Tefillin, although many other significant opinions identify with this position.
Actually, this dispute seems to have long pre-dated the days of Rashi and Rabbeinu Tam. For example, the Mechilta in our Parsha (פ' בא סוף פרשה י"ח) is cited by Tosafos (שם) as indicating that the order suggested by Rashi is correct, because it says that these four Parshiyos are inserted in the Tefillin because they are the four places where the Torah mentions Tefillin, and it then lists the Parshiyos in that order; the Midrash Tanchuma on our Parsha (שם אות י"ד) implies this as well. The Chida, however, in his Sefer Sheim HaGedolim (מערכת ספרים ערך ירושלמי) quotes those who write that there is a text in the Yerushalmi (which we no longer have today) which indicates that the correct order is as presented by Rabbeinu Tam.
The Mordechai, in his Sefer MeHalachos Ketanos, printed in the back of the Gemara in Menachos (הלכות תפילין, דף י: שם) writes that among those who hold like Rabbeinu Tam are Rabbeinu Chananel, Rav Sherira Gaon, Rav Hai Gaon, and the Rif; the Rashba (שו"ת הרשב"א המיוחסות להרמב"ן סימן רל"ד) cites Rav Saadyah Gaon as concurring as well. On the other side, the Rashba himself (שם) concludes that Rashi's order is correct, adding that Rabbeinu Yonah and the Ramban held that way as well; the Sefer HaChinuch (מצוה תכ"א) also accepts this position, and mentions that Rav Hai Gaon agreed to it too. In a Teshuvah, the Rambam (תשובות הרמב"ם הוצאת בלאו, חלק ב' סימן רפ"ט) also writes that Rav Hai Gaon himself wore Tefillin with the Parshiyos in the order that they appear in the Torah, and he asserts forcefully that this is the Halacha, as he rules in his Mishneh Torah (פרק ג' מהל' תפילין הלכה ה'); the Raavad, however, both there (שם) and in a Teshuvah (שו"ת תמים דעים סימן ע"ט) disagrees and accepts the other view.
In his commentary to the Tur, the Derishah (או"ח סימן ל"ד אות א'), among others, quotes sources which relate that an ancient pair of Tefillin, which had been buried, was uncovered and the Parshiyos therein were found to follow the order presented by Rashi, implying that this is the correct practice. But he adds that there may not be any proof from this story, since it was perhaps precisely because they were written with the Parshiyos in that order that these Tefillin were buried, because they were invalid, and really the practice was to accept Rabbeinu Tam's position. The Bach (שם בד"ה סדר) quotes this story as well, but considers this latter suggestion to be unlikely, and he concludes that the custom is to follow Rashi's opinion. It is noteworthy that Rabbeinu Yaakov of Marvish (one of the Baalei HaTosafos), in an interesting collection of Teshuvos written based upon communications from Heaven via dreams (שו"ת מן השמים סימן ג'), states that this dispute exists in the Heavenly court as well, and thus אלו ואלו דברי אלקים חיים, both practices are Halachically acceptable.
The Rosh, in his Sefer Halachos Ketanos, also printed in the back of the Gemara in Menachos (הלכות תפילין סימן ה'), writes that because so many great authorities dispute this matter, it is proper to have and put on two pairs of Tefillin, in order to fulfill both opinions. The Tur (או"ח סימן ל"ד) rules accordingly, explaining why this does not constitute a violation of Bal Tosif, which generally prohibits one to add to the performance of a Mitzvah. Rav Moshe Feinstein (שו"ת אגרות משה או"ח חלק א' סימן י"ג) develops this point at length. The Shulchan Aruch (שם סעיף א') states that the prevalent Minhag is to follow the view of Rashi and the Rambam that the Parshiyos must appear in the order they are found in the Torah, but he then adds (שם סעיף ב') that one who fears Hashem should indeed wear two pairs of Tefillin, having in mind that he fulfills his obligation with whichever pair is truly correct according to the Halacha, while the other is merely a set of straps. As noted by the Magen Avraham (שם ס"ק ג') and the Mishnah Berurah (שם ס"ק ח', ועיין שם בביאור הלכה בד"ה ויכוין), having this in mind will also avoid the problem of Bal Tosif because one of the pairs is invalid and is thus discounted.
The implication of these rulings is that these two pairs of Tefillin should be worn at the same time; the Taz (שם ס"ק ה') thus discusses which pair should be above which, noting that it is better to put both on at once so that the Berachos recited will count for both, as opposed to putting them on one after the other where the Beracha will not relate to the second pair. This idea is based on the statement of the Gemara in Eiruvin (דף צ"ה:) that there is enough space on one's head and on one's arm to simultaneously wear two pairs of Tefillin (properly). As noted in Tosafos (שם בד"ה מקום), however, such pairs of Tefillin must be very small; Rav Ovadyah Yosef (שו"ת יביע אומר חלק א' האו"ח סימן ג' אות י"ח-כ"א) documents that our Tefillin today are much bigger, and it is thus not proper to wear two pairs at once because at least one will lay in the wrong place. The Radvaz (שו"ת הרדב"ז חלק ו' סימן ב' אלפים רע"ו) already implies that it is difficult to wear two pairs of Tefillin at once, and the Magen Avraham (או"ח סימן ש"א ס"ק נ"ד) states that we lack the expertise today to properly wear two pairs at the same time. Perhaps with these ideas in mind, the Shulchan Aruch (שם סימן ל"ד סעיף ב') rules that if one is unable to wear the two pairs at once, one should put on the first pair, remove it right away, and then immediately put on the second pair so that the Berachos will go on both, or he should put on the Rashi Tefillin and wear them throughout Davening, and then put on the Rabbeinu Tam Tefillin afterwards without a Beracha, and recite the Parshiyos of שמע and והיה אם שמוע. The Mishnah Berurah (שם ס"ק י"ד-ט"ו) implies that the common practice of those who wear Rabbeinu Tam Tefillin is to follow this latter view.
It is worth noting that the Shulchan Aruch (שם סעיף ג') rules that Rabbeinu Tam Tefillin should be worn only by one who is known to be a very pious person; the Mishnah Berurah (שם ס"ק י"ז) explains that it is a sign of haughtiness for anyone else to do this because the accepted practice is to wear Rashi Tefillin. The Shaarei Teshuvah (שם ס"ק ו'), however, writes that if one is in a place where the practice of most people is to wear Rabbeinu Tam Tefillin, it is not a sign of haughtiness for one to do this, and it is thus permissible. Rav Ovadyah Yosef (שם אות כ"ב) adds that some hold that haughtiness is a problem only if the two pairs are worn at once, not if the second is put on after Davening. It is also worth noting that the Vilna Gaon (ביאור הגר"א שם בד"ה ומנהג) rules clearly that Rashi's view is correct, and is quoted by a Talmid of Rav Chaim Volozhiner (ספר כתר ראש אות י"ג) as having said that in order to fulfill all the different opinions about writing and positioning Tefillin, one would have to wear many more than two pairs. The Noda BeYehudah (שו"ת נודע ביהודה מהדורא תנינא חאו"ח סימן ד') explains, however, that people are more concerned about the dispute over the order of the Parshiyos because there are so many important authorities on each side of the issue. Rav Moshe Feinstein (שו"ת אגרות משה או"ח חלק ד' סימן ט') seems to agree, writing that his personal preference was to wear Rabbeinu Tam Tefillin after Davening when possible.