The origins of this discovery can be traced to the invention of that humble paraphernalia of the modern undergraduate laboratory, the Bunsen burner. In 1850's Gustav Kirchhoff and Robert Bunsen at the University of Heidelberg wanted to compare spectra of the light from stars with spectra one can produce on earth. They needed to heat metals to high temperatures to achieve this comparison. The blue flame of the Bunsen burner did the job.
These studies led Kirchhoff, more known to us for his circuit laws, to propose a classic challenge to theorists. His conjecture was that the spectrum of the radiation depended only on the temperature of the metal ( and hence that of the radiation gas) and on nothing else.