Setup: Spring (force constant k) + gas in heat bath. Piston at displacement x from equilibrium; gas volume V=V1+Ax where A is piston area.

Equilibrium condition: Fx=0

Fx=ExTSx

Energy term — gas is at constant T, so its energy doesn't change with x. Only the spring contributes:

Ex=Fpiston=kx

Entropy term — piston has no entropy; only the gas contributes:

Sx=SVVx=PTA=FgasT

Substituting:

Fx=FpistonFgas=0Fpiston=Fgas

Result: Minimising free energy is equivalent to balancing forces.