In essence, the number of pixels tells you how many individual light-sensitive areas the sensor of your digital camera has. Generally speaking, the more areas there are, the better the quality of the picture because a sensor with a lot of pixels will be able to capture the details better. This is similar to studying an object and dividing it into 100 pieces instead of 10 pieces.
If you divide the object into 100 pieces and study them individually, you will be able to study them better and will notice nuances that are likely to escape your attention when you look at only ten parts. In the exact same manner, a camera with a 20MP sensor will be able to capture many more fine details compared to a camera that has a sensor with 6MP.
At the same time, it is important to remember that the quality of your photos will depend not just on megapixels. Many 15MP dSLR cameras can produce better pictures than 20MP non-dSLR cameras because their sensors are physically larger. Some dSLRs can even perform better than dSLRs with bigger resolutions and sensors because of the quality of sensors and electronics.