When light is moving through a uniform medium, whether empty space or some other material, it moves at constant speed in rectilinear (straight-line) motion; but when it passes from one medium to another, its velocity may change, and if it does it may be refracted, or bent at the boundary between the two media.
(detailed explanation to follow, but for the moment...)
Light bends downward as it enters the atmosphere, because it moves (very slightly) slower in air than in the empty space beyond the atmosphere. The amount of bending is zero if the light is heading straight downward, perpendicular to the atmosphere, as it approaches us (in other words, if the object appears to be at the zenith). If the light hits the atmosphere at an angle, the light bends downward by an angle of up to half a degree, making the object appear that same angle higher than it would in the absence of refraction.
The result is that objects seen from the surface of the Earth appear to be "lifted" by a small angle, which depends upon their altitude, or height in the sky. Objects that are directly overhead appear to us to be in the same position they would be if there were no refraction, while objects which are near the horizon are lifted around a half-degree, and objects at in-between altitudes are lifted by in-between amounts. Near the zenith the amount of refraction changes very little as things appear lower and lower in the sky; but as they near the horizon the amount of refraction rapidly increases, so that the "bottom" of a disc such as the Sun or Moon may be noticeably closer to the "top" of the disc because of the increase in refraction in the fraction of a degree separating the two limbs. As an example, consider the lunar images below. As the Moon approaches the horizon its apparent width remains essentially unchanged (it gets a little smaller, because we are further from the Moon when it is near the horizon than when it is overhead, but the effect is small compared to the refraction); but the vertical size of the Moon seems to rapidly decrease as the bottom is lifted more and more, relative to the top.
A series of images taken by astronaut Don Pettit from the International Space Station, showing the full moon "setting" on April 16, 2003 (the "setting" being actually caused by the orbital motion of the Space Station). As a celestial object's light passes through our atmosphere it is bent, or refracted, making it appear higher than it really is. As the object nears the horizon the amount of refraction rapidly increases, so as the Moon sets its lower limb is "lifted" more than the top, making the Moon appear vertically squashed (but leaving its horizontal width unchanged). Scattering of light by the atmosphere, greater at shorter wavelengths than longer ones, also makes the Moon look redder as it descends. The same phenomena are observable on the Earth, but because the light of the "setting" Moon is bent when it passes into our atmosphere and is bent again when it leaves our atmosphere before reaching the Space Station, the effects shown here are doubled compared to the view from the ground. (Don Pettit, Les Cowley, ISS, NASA; apparently no longer online)