When a pencil is partly immersed in water and held in a slanting position, the rays of light coming from the immersed part of the pencil emerge from water (a denser medium) and enter air (a rarer medium). During this propagation, they bend away from the normal on refraction.
As a result, the immersed part of the pencil does not appear straight with respect to the part outside the water, but appears to be raised. Hence, a pencil dipped obliquely in water appears bent at the surface of the water.