What does rain 雨 have to do with mold 霉 and bad luck? Almost all the other characters with the 雨 component have relation to rain, clouds, and weather. However, this character 霉 seems to be the exception. It means mold, but the rain semantic seems very confusing. What does 霉 have to do with rain? And where did the term 倒霉 (fallen + mold) come from which came to mean &quot;unlucky&quot;?
《說文・黑部》 

黴，中久雨青黑。从黑，微省聲。
「黴」 (Zhengzhang OC: /*mrɯl/), blackening from being afflicted by prolonged rain. From semantic 「黑」 (black) and reduced phonetic 「微」 (/*mɯl/).


The character 「霉」 (mould, mildew) did not exist originally, with the word that it represents being originally written as 「黴」. From character definitions, 「黴」 originally referred to the dark mould spots on garments from prolonged exposure to moisture, such as when rain hits and causes an environment to be damp. This is the direct correspondence between mould and rain.

The correspondence between 「霉」 and unlucky is less certain, with the word being written variously throughout history as also 「倒楣」 and 「倒煤」. You can find folk etymology explanations, but the choice of the second character for this word is most likely just a phonetic loan.

References:

《王力古漢語字典》
中國哲學書電子化計劃

宋・徐鉉等奉敕校定　漢・許慎《說文解字》