A layer mask lets you hide or show select areas of a layer.
If you're hiding part of the image in layer1 the layer below, layer2 will show in it's place.
It's similar to erasing part of Layer1, the layer below will now show.
The advantage to using a mask instead of erasing is it's completely non destructive and reversible.
You can also use a mask to make adjustments to only specific areas of an image.
Here you see the shadow side of a very dark house.
I created a curves adjustment layer and lightened the image up until the house looked about right, I ignored the rest of the image, here's what I got.
A mask is automatically created with an adjustment layer.
I then inverted the mask (Ctrl+I) making the whole curves adjustment invisible.
With a mask, black hides, whites shows.
Now with a white brush on the inverted black mask I paint on the mask layers where I want the curves adjustment to show.
I've circled the mask and the corresponding affected area on the image.
I would continue to painting the darker areas until the the whole house was done.
I've made the adjustment visible on the top part of the house and left the bottom untouched so you cane compare before and after.