Refraction of light from going to one medium to another On the basis of ray theory can somebody please explain my why does light bend from going to one medium to another.Why can't it move in a straight line but with different speed ?
 A: I interpret "ray theory" as the ray approximation used in geometric optics (see Wikipedia). In this framework, refraction is assumed to be true, so it is an axiom. It is not derived from any lower-level principle. 
The principle can be usefully expressed in terms of shortest path (see the answer of Joe Iddon). However, this is still an axiom, not a consequence of other known facts.
In order to derive the refraction from a lower-level concept, we must at least consider wave optics (no need for quantum concepts). In the eikonal approximation (see Wikipedia), we get the usual refraction laws.
A: This is a tricky question to answer at the high level without delving deeply into Quantum Electrodynamics (QED).
Fermat's principle of least time states that out of all possible paths that it might take to get from one point to another, light takes the path which requires the shortest time.
The way Feynman explains it in his book QED is as follows:
You are a lifeguard trying to save someone in the water and are currently up the beach. You can run on land faster than you can swim.
As the extract from the book below shows, running extra on land in order to minimise distance in water may be faster than minimising distance in total (i.e. a straight line), but it is clear that the fastest route is to run to somewhere in between those two points.
And due to Fermat's principle of least time, is the path which light takes.

You can read a bit more about the principle of least time in Feynman's Lectures on Physics here, but I think the book where he really delves in to detail on the matter, QED, is not available for free online.

Note that Fermat's principle of least time (1650) still holds for lots of cases, but has been superseded by QED (1940) which can now predict the outcomes of every experiment of this nature to unbelievable accuracy.
