After the Sun, the first objects to be studied were stars. Regularities in their spectra led to the invention of the spectral types. Later the origin of the spectral types was understood as coming from the temperature of the surface of the star: Particular absorption lines can be observed only for a certain range of temperatures; because, only in that range are the involved atomic energy levels populated. Of particular importance are the absorption lines of hydrogen (which is found in the atmosphere of nearly every star); these are known as Balmer lines. A "typical" star, such as the Sun, radiates in the middle of the optical spectrum.
Stellar spectroscopy proved immediately useful in that it allowed scientists to figure out the composition of stars. The current stellar classification scheme originally referred to the strength of the hydrogen lines with A being the strongest. It was only later than a connection with temperature was found.
It was also responsible for the discovery of helium which was discovered in solar spectrum before being discovered on earth. What causes the lines in stellar spectrum remained a mystery until the end of the 19th century and the discovery of quantum mechanics.
Today, the spectra of main sequence stars is considered to be largely understood, and stellar spectroscopy is used as a tool to derive other quantities. For example, the spectra of a star can be used to derive the absolute magnitude of a star which can then be used to derive its distance. Stellar spectrum can also be used to derive the age of a star in that recently formed stars have a far higher concentration of elements heavier than helium than stars that were formed early in the universe.