High temperatures during a very hot sunny day will heat up the ground itself, which in turn will heat up the layers of air above the ground. If the layer of air sitting a fraction above the ground is hotter than any layers of air above that, then the light rays will bend in an upward concave path. The traveller looking through the bent or refracted light rays will now see a mirrored image of the sky above, appear like a water body on the ground.
If you place a pencil in a glass of water, you will notice that the pencil appears to be bent at the air and water boundary. This is how a mirage works because the density difference in the air layers (which is caused by the temperature differences) bends the light in a similar way.
A general rule of thumb when it comes to the temperature differences between the ground air and the air above in regards to mirages is outlined below:
No Mirage
No mirage will form, if the temperature difference of a metre above the surface is less than 1.7 degrees Celsius
Moderate Mirage
A moderate mirage will form, if the temperature difference of a metre above the surface is around 2.8 degrees Celsius
Strong Mirage
A strong mirage will form, if the temperature difference of a metre above the surface is over 4.4 degrees Celsius