The interior of the bubbles is mostly steam. When you raise the lid cold (well, below 100C) air flows in and the steam in the bubbles condenses and collapses the bubbles.
I don't know of anyone who has done the experiment, but you should find if you lift the lid when the outside temperature is 100C or greater the foam will not collapse, or at least it will collapse more slowly. Presumably you'd still get evaporation from the foam surface.
Edit: just out of curiosity I worked out how much air would have to enter the pan to condense the steam in the foam.
Density of steam at atmospheric pressure $\rho_s$ = 5.90e-4 g/cm3
Latent heat of steam at atmospheric pressure = 2.26 kJ/g = 0.00133 kJ/cm3
Suppose your pan contains 100cm3 of steam in the foam then the heat given off when you condense it to water at 100C is 0.133kJ.
The specific heat of air is about 1 J/(g.K) so assuming the air in your kitchen is about 20C, i.e. a temperature change of 80C when it hits the steam, you need 1.66g of air. The density of air is about 1.2g/litre so you need about 1.4 litres of air to fully condense the steam. I must admit that this seems a lot.
However you probably don't have to condense all the steam to collapse the foam. I suspect (but can't prove) that condensing the steam just inside the bubble wall would be enough to destabilise it and cause the bubble to break. The remainder of the steam in the bubble would simply escape and wouldn't need to be condensed, so the volume of air needed would be greatly reduced. Still, I have to concede that evaporation could well be an important factor.