both poster's offered great answers so i won't repeat them, just elaborate.
first of all its not just used on drums, its used on all tracks and there is no perfect setting. there is a compression culture, complete with styles, preferences, trends, and things like that.
as the previos poster's mentioned it reduces the dynamic range of audio.
the ratio is how much it will be compressed. for example, a 2:1 ratio would represent: for every two DBFS coming in, only 1 DBFS will go out.
the threshold is the dynamic range of audio that will be effected by the set ratio. anything under the threshold will retain original dynamics, anything above threshold will be dynamically destructed.
the attack is how quickly the compressor will inforce the ratio after the signal meets the threshhold. this is so you can let the batter head punch of a kick drum come through but then imediately compress the body of the sound without losing that front end transient.
release of course is when compression resides and dynamics return to normal. you don't want to compress a sound that has gone back down under the threshold but the compressor does not automatically release. you have to set it.
gain of course is to make up for volume lost when compression takes place. and the knee is for how quickly the compressor applies compression after attack time is met and threshold is broken.
a limiter is a compressor with a 100:1 ratio or higher.
google : side chain compression, parellel compression, and serial compression for some common techniques besides the basic use of dynamic destruction.