The core answer is that the arrangement is deliberate: the Rambam rules that the Chanukah lamp is placed at the handbreadth near the door on the left of one entering, so that the mezuzah is on the right and the Chanukah lamp on the left (Mishneh Torah, Chanukah 4:7), and the Shulchan Arukh and Kitzur Shulchan Arukh codify the same arrangement, surrounding the one who enters with mitzvot (Shulchan Arukh, Orach Chayim 671:7, Kitzur Shulchan Arukh 139:7).
This placement traces back to Chazal themselves: Tractate Soferim grounds it in the pasuk 'mah yafit u'mah na'amt' — yafit referring to the mezuzah on the right and na'amt to the Chanukah lamp on the left (Tractate Soferim 20:5), and the Gemara as cited in later sources frames it as the halachically settled position that the lamp goes left so that mezuzah is right (Maamar Mordechai Hilchot Chanukah 6:8, Sfas Emes al HaShas, Shabbat 22a).
The Tur transmits the same halachah and adds the proviso that if there is no mezuzah on the doorpost, the lamp is placed on the right instead, since a mitzvah object is given precedence for the right side, and also notes the custom in a synagogue to place it in the south, recalling the position of the menorah in the Beit HaMikdash (Tur, Orach Chayim 671), a provision further explained by the Mishnah Berurah, which adds that the right side is generally preferred for mitzvot and affords greater publicizing of the miracle since people typically turn rightward (Mishnah Berurah 671:33-34), and discussed by the Beit Yosef regarding the placement relative to the public domain and courtyard doorways (Beit Yosef, Orach Chayim 671:8).
Modern halachic writers continue to state this reasoning plainly: Rav Mordechai Eliyahu explains that the whole point is that one entering should be 'surrounded by mitzvot' — tzitzit worn on the body, mezuzah on the right, and the Chanukah lamp on the left, and that where there is no mezuzah the lamp shifts to the right (Maamar Mordechai Hilchot Chanukah 6:8, Maamar Mordechai Hilchot Chanukah 6:42, Maamar Mordechai Hilchot Chanukah 7:10), and Rav Eliezer Melamed likewise frames the left placement of the lamp as designed so that the person passing through is surrounded by mitzvot, mezuzah on the right and lamp on the left (Peninei Halakhah, Zemanim 13:1, Peninei Halakhah, Zemanim 13:3).
Beyond the straightforward halachic principle, several Hasidic sources offer a deeper rationale for why specifically mezuzah takes the right and the Chanukah lamp the left: the Shem MiShmuel explains that the mezuzah's function is to draw everything in the house upward toward devotion to Hashem, a quality associated with the right which 'draws near,' whereas the Chanukah lamp's function is to illuminate the public domain outward and push back external forces, a quality associated with the left which 'pushes away' (Shem MiShmuel, Chanukah 77:2, Shem MiShmuel, Chanukah 77:3); the Sefat Emet similarly ties the mezuzah to the direction of entry (right) and the lamp to the direction of exit (left) (Sefat Emet, Bereishit, For Chanuka 25:5); and other Hasidic discourses connect the lamp's leftward placement outside the home to its task of illuminating specifically the darkness of the public domain (Maamarim Melukatim ש״פ וישב, ערב חנוכה ה'תשכ״ו, Hemshech Ayin Beis 5675 ש״פ מקץ, ש״ח, העת״ר).
A minority or alternative view favoring the right side for the lamp is also recorded: the Chatam Sofer explains that one who stands in place performing a mitzvah, such as the Chanukah lamp or lulav, begins from the left and turns toward the right, parallel to the direction Hebrew letters are written in a sefer Torah (Responsa Chatam Sofer, Orach Chayim 187:8-9), while another reading connects a view favoring the right side specifically to its alignment with the mezuzah as one enters from outside, since the lamp's purpose is to illuminate outward and draw others toward holiness (Eretz Tzvi Moadim p. 181).
Several sources address practical variations rather than the underlying reason: the Radbaz discusses the synagogue custom of placing the lamp in the south wall and defends it against the charge of inconsistency with the doorway-based rule (Teshuvot HaRadbaz Volume 3 945:1-2); the Levush, Beit Yosef, and later authorities discuss the order of lighting additional candles from left to right or right to left depending on where the lamp stands relative to the mezuzah (Levush, Orach Chayim 676:5, Beit Yosef, Orach Chayim 676:3, Kitzur Shulchan Arukh Yalkut Yosef, Orach Chaim 676:20, Maamar Mordechai Hilchot Chanukah 7:44, Maamar Mordechai Hilchot Chanukah 7:51, Maamar Mordechai Hilchot Chanukah 7:47, Nishmat Shabbat vol 1:324); and the Tur elsewhere discusses the time for lighting rather than the right/left question (Tur, Orach Chayim 672).
Mishneh Halachos addresses a case where the mezuzah on the left doorpost is placed only as a stringency rather than as the essential requirement, ruling that the Chanukah lamp should nonetheless remain on the left, preserving the standard rabbinic arrangement of lamp-left, mezuzah-right (Mishneh Halachos 15:203).
Az Nidberu addresses the same left/right arrangement, noting that one source presents the placement as a mitzvah while another frames it as part of the original rabbinic enactment (Az Nidberu 7:69), and elsewhere explains that although the lamp was originally meant to be lit outside opposite the mezuzah, danger in exile led to the practice of lighting indoors instead, and separately discusses lighting in a window to publicize the miracle rather than strictly following the mezuzah-right, lamp-left arrangement (Az Nidberu 6:75, Az Nidberu 11:32).
The Recanati, discussing the mezuzah on its own terms, explains that it is placed at the entrance as a protective and elevating presence guarding the house from harmful forces, which provides background for why the mezuzah occupies the right side of the doorway even without addressing the Chanukah lamp directly (Recanati on the Torah, Vaetchanan:34).