Compression is a really simple tool which is not hard to grasp at all, but most people struggle with, so if you don't know how/why a compressor works, you're not alone!
You just need to know these few things:
You have Threshold, Ratio, Attack, Release, Gain.

* Threshold: Say you put a sample in your compressor which peaks at -9dB, the threshold will determine when the compressor should kick in. So if you set the threshold to anything higher than -9dB, it won't do anything (since the drum will never be louder). If you for example set it to -10dB, then it WILL kick in at any peaks above -10dB.
* Ratio: Now the ratio will determine how much to lower the volume. If you set your compressor to 2:1 it will turn down every 2dB that's over your threshold to 1dB, this means that if it's 4dB over the threshold, the compressor will make it 2dB and so on. With a compression of 3:1 it would turn down every 3dB that's over your threshold to 1dB and likewise if it's 6dB over the threshold, the compressor will make it 2dB and so on. In other words, ratio determines how much it will squash of the signal that's louder than we allow (with the threshold).
* Attack: The attack will determine how much time should have passed where the signal is over the threshold, until it compresses the signal according to the ratio.
* Release: This will determine how long it should compress the signal before letting the signal be uncompressed again.
* Gain: Gain will only let you change the volume after compression, so there's nothing special about that.

As you can see, this is relatively straightforward, but some people may be confused as to when and where to use compression. The saying usually goes "don't compress unless you need it," but it's non-trivial to know when you need it. A good tip is to apply it on things that should cut through the mix or should be snappy (like a snare for example).

A simple way to see how compression affects your sound is to do the following:
* Set the threshold to as low as you can (like -80d.
* Set the ratio to as high as you can (approx 10:1).
* Set the attack to 0ms and the release to maximum (maybe 300ms).
* Now you should only hear a small click on whatever sample you are using. This is a prime example of the compressor working. Tweak your settings from here to see how much compression you want.

Good things to bear in mind:
* Gentle compression can give a nice touch to things. In order to be gentle, have a fairly high threshold and a fairly low ratio.
* The attack should be fairly short if you want it snappy. Less than 10ms usually.
* The release should be adjusted to the speed of the song, so don't leave it at maximum.
* Compression alters the transients of your sounds, so be careful with what you compress.
* If your compressor has automatic make-up gain, turn it off. The reason for this is that it will seem like the threshold will turn the volume up, rather than down, because the compressor will make up for the volume that's lost to compression, by gaining it. Only enable this if you know what you're doing or else it will be counter-productive.
* Don't let the loudness fool you. Even though your compressed signal will be quieter than the original (and therefor probably subjectively sound worse), you should remember that you can use the gain.
* Hard compression hurts! go easy on the ratio-meter.
* Don't overcompress! It kills the transients and causes listener fatigue.

That's all there is to it! Now go on and experiment!"