晦气 is rooted in the concept of
晦 — the dark, moonless end of the lunar month, associated with yin energy and bad fortune. Calling something
晦气 expresses both bad luck and a sense of being tainted by misfortune. It's commonly used in everyday speech to vent frustration.