While 'behind the scenes' the workings of a digital camera are highly technical, using them doesn't have to be.
Camera manufacturers spend a lot of time and money developing systems which will analyse the scene and determine the 'appropriate' exposure value - and then use that to adjust Aperture / Shutter / ISO depending on which mode you are in.
All 'Exposure Compensation' does is AFTER the camera has calculates it's exposure value, to adjust it by your setting - then carry on as before.
@rob-nikon has given a couple of good examples of when you would want to do this - but there is also a third situation, which is when you are concerned about the the histogram (and this is perhaps a bit more technical).
Camera sensors can capture a limited range of brightness (called the Dynamic Range) - above this, you just get white, below, you just get black.
Sometimes you want to adjust the cameras exposure value to avoid this occurring - an example would be if you have a scene where there is a smallish very bright area in the scene.
If that bright area is something you want to preserve detail in (EG a swans feathers), then you might use negative exposure compensation to reduce the reduce the overall brightness, to prevent the swan becoming just a white blob.
If the bright area is the Sun, on the other hand, you might do the opposite, and use positive exposure compensation - the Sun will be a white blob regardless, so you can safely let that be white, and brighten the rest of the image.