1. When light travels obliquely from one transparent medium to another, the direction of propagation of light changes due to refraction of light.
2. In this case, light travels from denser medium to rarer medium, hence it bends away from the normal and the pencil appears to be bent.