A chemical system wants to reach the minimum free energy possible, and thus the reaction will take place until the free energies of the reactants and products are minimized. The relative concentrations of reactants and products when the free energy is minimized are the equilibrium concentrations, which can be used to calculate the equilibrium constant.
Here's a graph to illustrate what I mean:
http://www.chem1.com/acad/webtext/thermeq/TE-images/dGdGo_2.pngNote that the graph is of Gibb's free energy vs the reaction coordinate, not ΔG vs the reaction coordinate.
Locations 1 and 2 on the graph are the Gibb's free energies of reactants and products, respectively. Location 3 is the Gibb's free energy of the system at equilibrium. At equilibrium, when the Gibb's free energy is minimized, the ΔG value moving in either direction is positive (moving away from equilibrium increases the G of the system). As we know that positive ΔG defines nonspontaneity, the system won't move out of equilibrium if we don't mess with the system. If we start anywhere else on the graph, the process of moving towards equilibrium always results in a negative ΔG value, which means moving towards equilibrium is spontaneous. Moving away from the equilibrium concentrations has a positive ΔG value and thus doesn't happen.
Adding reactants or products moves the system out of equilibrium, and so the reaction takes place until equilibrium is reached again.
An equation relating Gibb's free energy and equilibrium is
ΔG = ΔG° + RTln(Q)
where R is the gas constant 8.3145 J/mol*K, T is temperature in Kelvin, and Q is the reaction quotient.
At equilibrium, ΔG = 0 and Q=K
eq, and so we may substitute and rearrange to get
ΔG° = -RTln(K
eq)
Now we have a clear way to relate the equilibrium condition with the overall change in the Gibb's free energy of the system. LeChatelier's principle is just a simple way to say that the system will try to reduce its free energy and thereby attain equilibrium.