When you look up at the sky at night with just your eyes, mostly what you see are a lot of points of light set against a more or less dark background. (More or less depending on light pollution and the presence or absence of the moon.) The points of light, with only a few exceptions, are stars, and about all you can tell from looking at them is that some are brighter, some dimmer, and some have a bit of color to them.
Not very much to go on, you might think. But there is more information packed into that little bit of light than you might realize. For starters, the brightness or dimness of a star depends on two things: how far away it is, and how bright it actually is. If we can figure out the one, we can get a good handle on the other, and that in turn will tell us how stars are distributed in space and something about how they actually work. Also, color is related to temperature, so just knowing the colors of stars can give us more clues about how they work.
But something far more profound is hidden in starlight. If you've ever played with a prism or even simply looked at a rainbow, you'll know that most of the time light is composed of an array of colors ranging from red to blue. Light is electromagnetic radiation, which can be described as a wave, and the color of light is dependent upon its wavelength. Red light has a longer wavelength than blue light. The light coming from the sun is a mixture of all wavelengths. A prism causes different wavelengths of light to bend at different angles, with the result that when sunlight passes through a prism, it is split into a rainbow, revealing all the colors of which it is composed. The technical term for this rainbow is spectrum.
The odd thing is, if you pass the light through a thin slit, then into the prism, and look closely at the results, you'll see that there are dark lines in the sun's spectrum, as you can see in the graphic at the upper left. (Click on it for a full-sized version.) It's as though for some reason the sun isn't radiating certain wavelengths of light. What causes this?
As you know atoms are composed of a bundle of protons and neutrons in the nucleus, surrounded by orbiting electrons. But electrons don't orbit the nucleus the way planets orbit the sun. Quantum mechanics states that orbiting electrons act like standing waves. Because of this, they can only occupy certain orbits, each of which has a specific energy level associated with it. Electrons want to be in the lowest energy state possible. Everything in the quantum world can be described as both a wave and a particle, and light is no exception. So let's suppose a photon (a particle of light) happens along and strikes an electron. What happens? Well, the electron absorbs the energy of the photon, which knocks it into a higher, more energetic orbit. It doesn't want to stay there, however, so after a very short time it will reemit the photon and drop back down to the lowest possible energy state. In the process, the photon most likely careens off in a different direction than it had originally been traveling.
That's what causes the dark lines in the spectrum of the sun, or of any other star. They tell us the frequencies of light that are being absorbed and reemitted by atoms in the outer part of the star's atmosphere. That may not seem like much, but it is, because it turns out that every atom has a particular "signature" of dark lines it creates. The light from a star, in other words, encodes the chemical composition of the star's atmosphere! So, by looking at spectra, we can discover what stars are made of, and the strength of the lines (how light or dark they are) can tell us the relative abundance of each element.
Nor is that all. Because light is a wave, it is compressed when the source of light is moving towards us and stretched when the source is moving away from us. This is called the Doppler shift, and you've no doubt experienced it with sound waves. In the case of sound, wavelength corresponds to pitch, so the pitch made by a noisemaker (say, a train's horn or a siren) coming towards you sounds higher than one going away from you. The shift from high to low is readily apparent when it passes you by.
Same thing with light, only since wavelength corresponds to color an object moving towards us looks bluer and an object moving away from us looks redder. With stars we wouldn't be able to tell just by their color, because we don't know what their color is when they are standing still with relation to us. But the dark lines in the spectra know. They always occur at the same wavelengths, so if they appear shifted to the blue or to the red, we can tell whether the object is moving towards us or away from us, and how fast it is going.
So now, light is telling us something about the distance to stars, the absolute brightness of stars, the composition of stars, the temperature of stars, and the motion of stars. I've simplified some of this a bit, but clearly light is a very powerful thing! Moreover, from this basic information, we can figure out a great deal more. Indeed, what we know as light is only the tiny part of the electromagnetic spectrum registered by our eyes. Infrared light and radio waves are the same thing only longer in wavelength, and ultraviolet light, x-rays, and gamma rays are shorter in wavelength. Today we use all of these to understand the composition, structure, and workings of the universe.
So there it is. If you've ever wondered how astronomers know so much about the universe when no man-made device has ever been anywhere near even the nearest star beyond our solar system, that basically is it. Light carries vast amounts of information. All we need to do is figure out what it's trying to tell us.