In the diagram on the right, ripples travel from the right and pass over a shallower region inclined at an angle to the wavefront. The waves travel more slowly in the shallower water, so the wavelength decreases and the wave bends at the boundary. The dotted line represents the normal to the boundary. The dashed line represents the original direction of the waves. The phenomenon explains why waves on a shoreline never hit the shoreline at an angle. Whichever direction the waves travel in in deep water, they always refract towards the normal as the enter the shallower water near the beach.
A well-known optical example of this is looking into a bowl of water. Air has a refractive index of just over 1, and water has a refractive index of about 1.3. If you look at a straight object, such as a ruler, which is placed at a slant, partially in the water, the object appears to bend at the water's surface. This is due to the light rays from the object being bent as they move from the water to the air.This causes water to appear shallower than it really is.
Refraction is also responsible for rainbows and for splitting up of white light into a rainbow-spectrum as it passes through a glass prism. Glass has a higher refractive index than air and the different frequencies of light travel at different speeds (dispersion), causing them to be refracted at different angles. The different frequencies correspond to different colours observed.
The amount that the light bends during refraction is calculated using Snell's law.
Recently some materials have been created which have a negative index of refraction (http://physics.ucsd.edu/lhmedia)