A blackbody is an object that absorbs all electromagnetic radiation that hits it and re-emits it at a range of wavelengths determined solely by its temperature. The shape of a blackbody’s spectrum is always the same, but the peak of the spectrum shifts to shorter wavelengths (higher energies) as the blackbody’s temperature increases. (This is why a cold piece of metal at room temperature appears dark, but if heated in a fire it will begin to glow red, then orange, and then white as the peak of its emission shifts to shorter wavelengths.)
It turns out that stars are well-approximated as blackbodies. Our Sun, for example, has a temperature of 5800 K, which puts the peak of its spectrum at about 500 nm — which is the wavelength of green light. It makes sense that our eyes evolved to see a narrow range of wavelengths corresponding to the peak of the solar spectrum!
Since the peak wavelength of a blackbody spectrum is inversely proportional to its temperature, all astronomers have to do to obtain the temperature of a glowing object is to measure its spectrum and determine the peak wavelength. This is incredibly useful for studying stars. Another tool that is important for stars and the ISM alike is the study of spectral lines.