How do the molecules of reacting compounds proceed to form "Most Stable" molecule? This question is a cross post from chemistry. I'm not very convinced with the answer there. So, I'm posting it here.
I'm tutoring few students for Chemistry. During the course, I many times use the phrase "Out of these possibilities this one is stable. So it is formed". I get questions like, "How do the molecules know?"
Honestly I don't know.  How do they proceed to form "Most Stable" compound?
 A: Molecules don't know. Consider the following reaction as a template for some reaction that is favored to go in the direction indicated.
\begin{align*}
A-B +C \rightarrow A-C +B
\end{align*}
In a large collection of such molecules you can always find some $AB$ going to $AC$ and some going backwards. It is just that significantly more $AB$ are going to $AC$ so you when you look into your beaker (system/experiment) you see that you are forming $AC$. 
Next question is why or when is $AC$ preferred? 
The process of the reaction is such that $AB$ is flying around doing its thing when $C$ smacks into with enough energy to form a transient state $B-A-C$. Now from this state it can forward $AC+B$ or go back to $AB+C$. This is the highest energy state and all the energy is jostling between these two "bonds" (interaction might be a better word). This state is called the transition state. For any particular set of molecules in your beaker (a large number ~Avogadro number) the path forward or backward has to go through this transition state. 
Think of what it takes to get to the transition for any set of molecules. In going from $AB$ to $BAC$ it requires the $C$ to come in with kinetic energy that is the energy difference between the energy of $BAC$ and $AB$.  Similarly to go from $AC$ tp $BAC$ it requires a $B$ to come in with kinetic energy that is the difference in the energy of $AC$ and $BAC$. It is now intuitive that if $AC$ has significantly lower energy than $AB$ it is less likely to find a higher kinetic energy $B$ than $AB$ finding a relatively less energetic $C$.  This is why if $AC$ is the significantly lower energy product, i.e., the reaction above is exothermic the forward direction is preferred.
Caution: I have been a little sloppy in my explanation. Because there are many many particles in the system, many other reactions are possible, e.g., $AC$ splitting itself apart into $A$ and $C$, $C$ not hitting $AB$ from the $A$ side and forming $A-B-C$ instead of $B-A-C$ in which case it cannot form $AC$ it can only form $A+BC$ etc. All this is part of what defines the chemical kinetics of the system. Furthermore the fact that there are many instances of these reactions happening simultaneously, one can study this system using statistical means. This is what is done when one says "thermodynamically" the free energy $\Delta G$ is minimized in the reaction. I saw that people have given you that explanation in Chemistry so I will not reproduce it here. 
Summary: A stable product is the one energetically favored or more precisely "free" energetically favored (lowest free energy). But molecules are going either way they don' know. More of them going the right way succeed! The ones that went wrong way eventually bump into guys that are going the right way are are forced to make a U turn.  
A: The answers you got on Chemistry are fine. 
Above the QFT level, physical systems find optima by a combination of randomness and asymmetric gradients. In this case the energy requirement for going from a prefered state to a less prefered one is higher than for the oposite reaction (which is roughly what is meant by "most stable" in the first place).
At the quantum field theoretical level they find stationary states in the dependence of te phase on the path, but that's a different mechanism.
A: To understand this you need to start from the point there is no such thing as an irreversible reaction.
As an example take some simple model gas phase reaction where A and B collide and the reaction forms C and D. The reagents A and B collide with at least the activation energy, react to form C and D, then the products C and D fly off with more energy than A and B started with. The extra energy comes from the enthalpy of reaction.
But now look at this in reverse. If C and D collide with enough energy there is a chance they will react to form A and B, and A and B will fly off with less energy than C and D started with. Energy is lost because now the reaction is endothermic. But can C and D have enough energy for this reverse reaction to take place? Yes, of course they can, because the energy they need for the reverse reaction is exactly the energy they got from the first reaction. So both the forward and backward reactions are possible.
But, and here's the key observation, the products C and D are likely to quickly collide and thermalise with the rest of the gas, so they lose the energy they need for the reverse reaction. This means the reverse reaction is much less probable than the forward reaction. The reverse reaction will happen, because the tail end of the Maxwell-Boltzmann velocity distribution will have enough energy to drive it, but because it's much less probable the forward reaction will be much faster. So when you start with pure A and B most will react and you end up with mostly C and D and just a trace of A and B left over.
And this is the point. The reagents don't know which end product is most stable. They react and back react to form all possible end products, and the product(s) we end up with are the ones that have the highest probability of formation.
I've given a rather rough example above, but the idea is quite general. If you have some reacting system then for each possible reaction there will be an equilibrium constant related to the Gibbs free energy change by:
$$ \Delta G = RT ln(K) $$
No matter how large the Gibbs free energy is, the equilibrium constant will always be finite i.e. the equilibrium is dynamic and the system will explore all possible configurations.
