The meaning and figurative use of "moths flying into the flame" explained in one go
"Moths flying into the flame" is a very widely known idiom; its literal meaning is a moth flying toward a firelight. Because most moths that dive into a flame are burned to death, people use it as a metaphor for bringing about one's own destruction, and it is also often used to describe someone who clearly knows there will be no good outcome yet still rushes in regardless of everything.
This expression has an early origin; it is generally believed that wording such as "moths darting into fire" already appeared in history books of the Northern and Southern Dynasties period, and it later gradually took its present fixed form as an idiom. There is also a folk two-part allegorical saying, "moths flying into the flame, bringing about their own destruction," whose meaning is plain at a glance.
From a scientific point of view, moths flying into a flame is actually a manifestation of insects' phototactic behavior. Moths are mostly active at night and usually rely on natural light sources such as moonlight to judge direction when flying; after encountering a lamp, they easily end up circling the light source, getting closer and closer, and finally hitting the lamp. So moths are not really seeking death, but rather have their sense of direction disrupted by the light.
When using it, note that "moths flying into the flame" has a clearly negative connotation and mostly appears in situations of criticism or admonition. For example, if someone insists on investing even after knowing it is a scam, or gives without regard for the consequences in a relationship, this term can be used to describe it. Words with similar meanings include "bringing about one's own destruction" and "walking into a trap oneself," which can be chosen according to the specific context.
Related reading