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.