basically, when you paint black on a layer mask, you are painting OPACITY. When you paint White on a layer mask, you are painting TRANSPARENCY. the effects of the layer will not show through OPACITY, while it shows through TRANSPARENCY. thus you can control the effected area of your layer by painting black and white on the mask.
this is useful if lets say you just want to brighten the subjects face alone.
1. select a levels layer mask
2. brighten up to the desired levels
3. paint everything black on the layer mask
4. paint white over the subjects face on the mask.
transparency on the mask on the face means that the levels that you have set effect only the face of the subject...
hope these detailed desciptions help. and of course, layer masks do more than just levels. from curves, hue/saturation, gradient map... etc... go experiment....