And one must say according to this that which we say, that one is obligated to touch them at every hour, this is its explanation: at every hour that he remembers them – he is obligated to touch them, in order not to come to a distraction of the mind (Bach and Magen Avraham, subsection 1). That is to say: for if even at the time he remembers he does not touch them – he might forget about them entirely, and come to lightheadedness or to passing gas or to a fixed sleep. And similar to this I found in the book Or Zarua HaGadol (siman 585), and this is his wording: A person is obligated to touch… Therefore a person must, when he is wearing tefillin, remember that tefillin are upon him and not distract his mind from them, so that he does not sleep in them and does not pass gas in them. For because he remembers that he bears the Honored Name upon him – he does not come to lightheadedness, and he grasps the fear of Heaven in his heart… Therefore when a person directs his heart in his prayer or in Halacha – this is not a distraction of the mind, for all the more so there is fear of Hashem. And we conclude in the chapter "He Who Sleeps" that one may sleep in them a brief sleep… Thus far his words. Behold, the main intention is so that he will come to fear of Heaven and not to lightheadedness. And a brief sleep is permitted, as this is a human necessity. (And with this the difficulty of the Sha'agat Aryeh, siman 39, is answered, for behold, laughter and lightheadedness are forbidden regardless, see there. And according to what I wrote it works out well, for this leads to that. And that which we say in Shabbat 12a: A person may go out with tefillin on the eve of Shabbat at nightfall, since he is obligated to touch them – he will certainly remember them, see there, this is its explanation: since he must not refrain from touching them every time he remembers, he will certainly remember and touch them, and remove them from upon himself at nightfall. Examine it and you will find it simple.)
וצריך לומר לפי זה הא דאמרינן שחייב למשמש בכל שעה, הכי פירושו: בכל שעה שנזכר מהם – חייב למשמש, כדי שלא לבוא לידי היסח הדעת (ב"ח ומגן אברהם סעיף קטן א'). כלומר: דאם גם בשעה שיזכור לא ימשמש – יכול לשכוח עליהם לגמרי, ויבוא לידי קלות ראש או לידי הפחה או לידי שינת קבע. וכעין זה מצאתי בספר אור זרוע הגדול (סימן תקפ"ה), וזה לשונו: חייב אדם למשמש… הלכך צריך אדם כשהוא לבוש תפילין לזכור שתפילין עליו ולא להסיח דעתו מהן, שלא יישן בהם ולא יפיח בהם. כי מחמת שזוכר שנושא שם הנכבד עליו – אינו בא לידי קלות ראש, ותופס יראת שמים בלבו… הלכך כשאדם מכוין לבו בתפלתו או בהלכה – אין זה היסח הדעת, דכל שכן דאיכא יראת השם. ואסקינן בפרק "הישן" דישן בהם שינת עראי… עד כאן לשונו. הרי דעיקר הכוונה הוא כדי שיבוא ליראת שמים ולא לקלות ראש. ושינת עראי מותר, שזהו הכרחית לאדם. (ומתורץ בזה קושית השאגת אריה סימן ל"ט, דהא שחוק וקלות ראש בלאו הכי אסור, עיין שם. ולפי מה שכתבתי אתי שפיר, דזה מביא לזה. והא דאמרינן בשבת יב א: יוצא אדם בתפילין ערב שבת עם חשיכה, כיון דחייב למשמש – מידכר דכיר להו, עיין שם, הכי פירושו: כיון שאין לו למנוע מלמשמש בכל עת שיזכור, בוודאי יזכור וימשמש, ויסלקם מעליו עם חשכה. ודייק ותמצא קל.)