Layers are a central concept in digital painting.
With layers you can get better control over your artwork, for example you can color an entire artwork just by working on the separate color layer and thereby not destroying the line art which will reside above this color layer.
Furthermore, layers allow you to change the composition easier, and mass transform certain elements at once.
Masks on the other hand allow you to selectively apply certain effects on a layer, like transparency, transformation and filters.
Check the Introduction to Layers and Masks for more information.