Surface tension
As contaminants', or surfactants', concentration in the bulk decreases, the surface concentration increases; this increases surface tension at the liquid-vapor interface. Surface tension describes how difficult it is to extend the area of a surface. If surface tension is high, there is a large free energy required to increase the surface area. The surface of the bubbles will contract due to this increased surface tension. This contraction encourages the formation of a foam.