A star encodes in its spectrum the complete chemical history of the molecular cloud it formed from, the nucleosynthetic history of every previous generation of stars that seeded that cloud with heavier elements, and its own internal dynamics through oscillations and surface activity that carry information about its core. When you read a stellar spectrum you are reading a compressed archive of cosmic history going back billions of years.