Before paper was invented, ancient Chinese scribes wrote historical records on slips of green bamboo. “青史 (qīngshǐ)“—literally “green history”—thus became a poetic and literary term for the historical annals. Therefore, 名垂青史 literally means “a name handed down on the bamboo slips of history.”
The idiom 名垂青史 taps into a core value in Chinese culture: the profound desire for a lasting, positive legacy. It's not enough to simply live and die; a meaningful life is one that contributes to the family, society, or the nation in a way that brings honor and is worthy of being remembered. This concept can be compared to the Western idea of “going down in history” or “achieving immortality,” but there's a crucial difference. In the West, one can “go down in history” for being infamous (e.g., Al Capone) as well as for being a hero. However, 名垂青史 is almost exclusively positive. It carries a strong moral weight. You cannot 名垂青史 through evil deeds; you can only do so through virtue, great achievement, or noble sacrifice. This idea is deeply connected to Confucian values, which emphasize an individual's duty to society and the importance of setting a moral example for future generations. Achieving this kind of historical recognition is seen as the ultimate honor, not just for the individual but for their entire family line.
名垂青史 is a formal, literary idiom. You won't hear it used in casual, everyday conversation about mundane topics.