וכל עת שייכנס וייצא, יפגע בייחוד שמו של הקדוש ברוך הוא--ויזכור אהבתו, וייעור
משינתו ושגייתו בהבלי הזמן; ויידע שאין שם דבר העומד לעולם ולעולמי עולמים, אלא
ידיעת צור העולם, ומיד הוא חוזר לדעתו, והולך בדרכי מישרים. אמרו חכמים, כל
מי שיש לו תפילין בראשו ובזרועו, וציצית בבגדו, ומזוזה בפתחו--מוחזק לו, שלא
יחטא: שהרי יש לו מזכירין רבים; והן הן המלאכים שמצילין אותו מלחטוא, שנאמר
"חונה מלאך ה' סביב, ליראיו; ויחלצם" תהילים לד,ח.
I just moved into my "new" house. To make an understatement, a lot of work still needs to be done. Many of the doors have yet to be put up. Additionally, many of the doorways have no m'zuzot and accompanying mashkof's. Sleeping in such a room gave me a deeper insight into why the mitzva is to affix the m'zuza to the doorway. I had a very clear feeling of insecurity in not having a door to close. I needed no privacy because the only other person living in the house is my wife. The door wasn't needed to give us protection from intruders because our front door was closed (of course the lock wasn't working). Even so, the feeling of insecurity was there. The closed door offers a psychological security - the feeling of privacy, the feeling of keeping out any force that could disturb my restful, serene state. Affixing the m'zuza to the structure that holds the door in place is the ideal location to reflect on yichud Hashem. No physical structure can offer security.
The doorway seems to be a place where primitive fears of malevolent forces become focused. Beyond the door is the outside unfriendly and unfamiliar world which stands in opposition to one's will; behind the door is the safe familiar environment of one's own design. One's primitive element attributes the dangers of the world to conscious forces (demons, shaidim). One must overcome this primitive orientation and be tamim im Hashem. In summary, the m'zuza 1) counters the notion that a physical structure can offer real security; 2) is a salvo against the primitive element of man (conscious or unconscious belief in shaidim).
My students brought to my attention that the young child often prefers to keep his door open when he sleeps (especially after seeing a scary movie). This is because the child is insecure in his aloneness. The child fears independance and looks to the parent for security. The doorway is the "door" to the child's lifeline - the parent.
(The text in this color was added on 5-4-06)