The grand canonical ensemble handled a system exchanging particles with its surroundings, and that is where the chemical potential \mu came from. As temperature answers to energy, \mu answers to particle number.
The two boxes in the figure are exchanging. Move one particle from left to right and the free energy on the left falls by \mu_1 while the right rises by \mu_2.
If moving it lowers the whole, the particle moves. So while \mu_1 > \mu_2, particles keep flowing from left to right.
Lose particles and \mu falls; gain them and it rises. So as they flow, the two chemical potentials draw together.
The figure is that drawing together. Where they become equal, moving a particle either way no longer lowers the whole. That is equilibrium.
It has exactly the shape of heat ceasing to flow once the temperatures are equal. Temperature answers to heat, chemical potential to particles. For each thing exchanged there is one quantity that must come into balance.
A chemical reaction is an exchange in which the kinds of particle are swapped. In a reaction making C out of A and B, one A and one B are lost and one C is gained.
The change in free energy for that is \mu_C - \mu_A - \mu_B. Negative and the reaction goes to the right; positive and it goes back to the left. It stops when it reaches 0.
Written together, \sum \nu_i \mu_i = 0. The \nu_i are the coefficients of the reaction, negative for what is used up and positive for what is made. The figure follows that working. Not one new assumption has been put in.
For an ideal gas the chemical potential takes the form \mu_i = kT\log n_i + \mu_i^0. That the concentration enters through a logarithm is the essential point.
Put that into \sum \nu_i \mu_i = 0 and undo the logarithms, and it becomes \dfrac{n_C}{n_A n_B} = K(T). A product and quotient of concentrations equal to one number fixed by the temperature alone. This is the law of mass action.
The figure is concentrations drawing towards equilibrium. Start anywhere and they come to rest at this ratio. A law taught in chemistry has come out of one balance of chemical potentials.
Inside K sits e^{-\Delta E/kT}. \Delta E is the energy the reaction changes by, and it settles where equilibrium falls.
The figure is how K moves with temperature. For a reaction that takes heat in, raising the temperature raises K and pushes towards what is made. For one that gives heat out it is the other way about.
What is known as Le Chatelier's principle comes, here, out of the single factor e^{-\Delta E/kT}. The Boltzmann factor of the canonical ensemble was settling the direction of chemical reactions all along.