In general, we call a reaction spontaneous if the reaction results in a decrease in the free energy of the system (i.e. ΔG < 0). This relationship can be derived from the second law of thermodynamics as follows:
The second law states that the entropy of the universe is always increasing (ΔSuniv > 0). There are two components to the entropy of the universe which we must consider, the entropy of the system and the entropy of the surroundings. By splitting the entropy of the universe into these two components, we can write the second law as follows:
ΔSuni = ΔSsys + ΔSsurr >= 0
Recall that for a reaction occurring at constant pressure, the change in enthalpy is equal to the amount of heat released/absorbed by the system, ΔH = q. Further, remember that the change in enthalpy of the surroundings is given by the following formula: ΔSsurr = q/Tsurr. Therefore, the quantity ΔH/Tsurr will tell you about the change in entropy of the surroundings.
Given that ΔSsurr = -ΔH/Tsurr, we can plug this value into our expression for the entropy of the universe to give:
ΔSuni = ΔSsys + ΔSsurr = ΔSsys - ΔH/Tsurr
Applying the second law, we obtain the inequality:
ΔS - ΔH/T >= 0
Or, equivalently:
ΔH - TΔS = ΔG <= 0
Which is exactly the equation that explains why spontaneous reactions tend to minimize their free energy.