Beer contains a large number of protein and peptides from malt and other raw materials. These protein and peptides can be gathered together to play the role of surfactants, making the beer foam lasting and stable and not easy to burst.
Hops also contribute to the lasting stability of foam. Hydrophobic peptides in malt materials are connected with picric acid from hops, which makes the surface of bubbles form teeth and enhances its viscosity and stability.