As you correctly state in your question:
There is a belief by some in a correlation between poor luck and unkosher Mezuzahs.
However, there is also opposition to this idea. Most notably, Rambam writes in Hilkhot Mezuzah (5:4):
מנהג פשוט, שכותבין על המזוזה מבחוץ... שדי... אבל אלו שכותבין בה מבפנים שמות מלאכים, או שמות קדושים, או פסוק, או חותמות--הרי הן בכלל מי שאין להן חלק לעולם הבא: שאלו הטיפשים, לא דיי להם שביטלו המצוה; אלא שעושין מצוה גדולה, שהיא ייחוד שמו של הקדוש ברוך הוא ואהבתו ועבודתו, כאילו היא קמיע להנית עצמן, כמו שעלה על ליבם הסכל שזה דבר המהנה בהבלי העולם.
There is a widespread custom of writing 'Shaday' on the mezuzah from the outside [of the parchment]. However, those who write in the mezuzah names of angels, or sacred names, or a verse, or seals--they are included in those who have no share in the world to come. For these idiots--it is not enough that they failed the fulfillment of the mitzvah, but they [even] render a great mitzvah; [whose essence is] the unity of God's name, and love for him, and his service, into a [mere] amulet for personal benefit, as occurred to their foolish minds; that this [mezuzah] is something that yields benefit in this world. (translation my own).
So, although the sentiment of the mezuzah as a protective amulet, to be checked in time of danger, was present even in Rambam's time, he was deeply opposed to it.
Although some attacked Rambam for his stance in light of sources that indicate protective powers, R. Qafih z"l writes (commentary to Hilkhot Mezuzah 6:13):
ואין כוונת חז"ל לדעת רבנו שהמזוזה מהנה בעניני העולם הזה, אלא שבזהירות במזוזה ישווה ה' לנגדו תמיד, ובכך תהיה השגחת ה' עליו גדולה
To paraphrase : According to Rambam the mezuzah does not provide earthly gain. Rather, through attention to the mezuzah, one will set God in front of himself at all times, and through this God will watch over him more.
This last point of R. Qafih brings Rambam a little closer to the others. Even though he does not believe that the mezuzah directly causes any physical benefits, R. Qafih suggests, that if one takes heed of the mezuzah's message, and allows it to keep God on his mind, he will merit a greater degree of divine intervention in his life, including, potentially, physical benefits.
Although there were some who were so entrenched in the belief that mezuzot provide physical protection that they even claimed that Rambam held this, this is not the implication of the aforementioned quote, or the understanding of R. Qafih, one of the greatest experts on Rambam (and Geonim and North African / Spanish Rishonim in general) of all time.
Similarly, R. Wolf Boskowitz writes:
אלא ודאי מוכח מזה דרבינו ז"ל סובר דמצות מזוזה אין בו תועלת השמירה כלל בטבעה ובסגולתה, רק כי היא כמו אחת מכל מצוות ה' אשר צוה אשר אין בהם תועלת לעניני עולם הזה
To paraphrase: It is evident form this that our master [Rambam] is of the opinion that the mitzvah of mezuzah accomplishes no protection at all. Rather, like all of the mitzvot, it does not provide physical benefit.