A pencil partly immersed in a glass tumbler filled with water appears to be displaced at the interface of air and water because:
Light does not travel in the same direction in all media
Light rays while entering a media change their direction depending upon the density of the medium. As water is a denser medium with respect to air, light rays bend towards the normal. When this bent light reaches the eye, the pencil appears to be displaced or distorted.