Pages I've read about worms' respiratory systems says that the skin needs to be wet (covered in mucus) or oxygen won't diffuse across the skin. Why? If there is more oxygen outside the worm's skin than inside, what prevents it from diffusing across the skin, even if the skin is dried out?
The quick answer: When the skin dries, the lipids in the cell membranes of the skin tissue undergo a phase transition which makes the membranes less permeable for oxygen.
Explanation: The lipids of the cell membrane can exist in different phase states. In the liquid disordered phase the lipids are relatively flexible and mobile, making this phase more oxygen permeable compared to the liquid ordered phase, in which the lipids are more rigidly packed.
The phase transition temperature of lipids increases upon dehydration (another reference), meaning that at the same ambient temperature, a dry lipid membrane is in the liquid ordered state and a wet lipid membrane is in the liquid disordered state.
Therefore, a dry cell membrane is less oxygen permeable than a wet one.
Because you are talking about diffusion, thus there needs to be a continuous pathway of gas or liquid for the molecule to move through. Membranes stop behaving like liquid when you dehydrate them. Oxygen cannot diffuse through extracellular solids (not at a meaningful rate anyway), which is all that is left why the skin dries out, so there needs to be a liquid path for it to follow. The water around a cell membrane helps weaken the binding energy allowing materal to pass between the lipid molecules, without the water is becomes a functional solid.
Skin does not replace water with air when it dries out, it collapses in on itself losing volume so all you have is solids (or things close enough to solid to act as a barrier), those no path for the oxygen. It is the same reason CO2 cannot diffuse through a coke can, it can't diffuse through a solid.
Edit, there is some gas exchange but it is very minor especially compared to what happens normally, and occurs because there is an occasional gas path. Cell membranes can be diffused across, but they slow it down, layer upon layer of them packed tightly as you have in dehydrated skin produce much the same effect as a solid, reducing the diffusion rate the point it can barely be measured and is nowhere near what the organism needs.
Animals that do not need ot gas exchange across the skin add layers of waxes to the skin making it an even better barrier and thus making it even more water tight.
Respiration in aquatic organisms involves diffusion of dissolved gases present in the aquatic medium across their permeable cell membrane . In worms which lives in moist environment the skin functions as a respiratory surface and requires the surface to be moist to enable exchange of gases.