Mirages occur when there is a rapid shift in air density in the atmosphere -- when the air at one level is a lot hotter than the air at an adjoining level (check out this page to find out why hot air is less dense than cold air).
This commonly occurs on summer days, when an asphalt road that has been baking in the sun heats the air directly above it, creating a sharp shift in air density levels near the ground. As light passes between the different levels, it bends, creating mirages.
Normally, sunlight bouncing off an object (let's say a car) reflects in all directions. You see the car when your eyes detect this light. On an overcast day, you only see the light that bounces off the car straight toward you. This is how you see things most of the time.
On a sunnier day, the light heading straight toward you acts just like it usually does -- it doesn't move through different layers of air density, so it doesn't bend much. But some of the light that would normally hit the ground actually bends in midair because it moves from the cooler, denser air level into the hotter, less dense air right above the ground. As you can see in the diagram below, this produces an interesting effect.
The lower part of the light wave passes between the layers first, so it speeds up an instant before the upper part. The light that would ordinarily go straight to the ground bends upward and travels to your eyes. The effect is that you see the image of the car twice: once on top of the road, and once in the road surface. The light from the lower part of the car bends farther upward than the light from the top of the car, so the mirage image looks like a reflection. Your brain assumes that the light is traveling in a straight line, so it seems like there's a mirror image beneath the normal image. This mirage looks just like a puddle of water on the road because, like a puddle of water, it's reflecting what's above it. This sort of mirage is called an inferior mirage because it appears below the horizon.
Superior mirages are mirages that form above the horizon. This occurs when there is a cooler level of air lower than a warmer level of air, typically over icy landscapes or very cold water. This mirage causes you to see a scene much higher than it should be. For example, you might see a mass of land or a boat floating in midair. This situation might also distort images, making a boat seem much taller than it actually is.
You can see a similar optical illusion any day when the sky is clear. As light from the sun enters our atmosphere, it slows down considerably. As a result, it bends toward the Earth. When the sun is low in the sky, it appears to be higher than it actually is because of this refraction. When it looks like the sun is about to drop below the horizon, it already has. The atmosphere is bending the light around the curve of the globe!
For much more information on mirages and other effects of refraction, check out the links on the next page.