Mirages are optical illusions caused by the bending of light rays due to temperature variations in the air. When the air near the ground is significantly warmer than the air higher up, light rays traveling through the different air layers are refracted, creating a distorted image of distant objects. Factors that influence the appearance of mirages include temperature gradients, humidity levels, and the angle of observation.