The primary reason to compress audio is to reduce dynamic range. The less dynamic range an audio signal has, the easier it is to mix with other signals. Imagine a folk singer using emotive volume changes over a light acoustic guitar melody. Now imagine trying to do this over a punk band. It wouldn't matter what volume you set the vocals to, it would either be too soft or too loud. Compression solves this problem, and the singer in our aforementioned punk band helps by singing at more consistent volume levels while using rhythm and timbre to create interest.
Another way to use compression is as an effect. By flattening a signal's dynamics, extreme compression can make a sound 'two-dimensional'. Think about blues and jazz recordings from the first half of the 20th Century. They have a sepia, music-box quality to them that is a result of, amongst other things, limitations with recording media that meant everything was highly-compressed by default. By softening sharp attacks and increasing the volume of fading notes, high levels of compression can also give instruments like guitars a languid, singing quality with an almost infinite sustain.
Sidechaining is a form of compressor automation that is invaluable when mixing kick- and bass-heavy music. Instead of having the compressor watch the volume level of the track it's on, it watches the level of another track entirely. This makes one track react to another, having its volume reduced low whenever the guide track is high. Used mostly with a bass track watching a kick, it frees up overall volume and frequencies, allowing the kick to hit as hard as possible without becoming muddy. The 'pulse' of the bass changing form in syncopation to the kick is also a desirable effect that makes dance tracks really pump.
As mentioned above, limiting is an extreme form of compression that dramatically reduces a signal's volume once it hits the threshold. This effectively creates a 'hard ceiling' that a signal can't exceed. Limiting is useful on tracks that have strong peaks which push 0dB, as it can stop them from distorting -- though this is admittedly more of a band-aid than a desirable effect. More commonly, limiting is used on rough mixes or final masters to push the perceived volume of a track up to a certain level without clipping. Be careful though, even moderate limiting can crush transients and kill a track's 'vibe' very quickly.