in a very simple way of explaining it.
if you play the sub in free air, the sound wave that comes from the rear of the cone would cancel out the sound wave that comes out the front side of the subwoofer cone, so by installing the subwoofer on a large baffle or in an enclosure, you keep those two sound waves from interacting in that manner that will cancel them out from each other, to a certain extent. you also increase the frequency response of a speaker by installing the driver in a proper system environment. now if in a sealed enclosure, to get the desirable frequency response from the subwoofer you have to manipulate the amount of air volume in the enclosure, in relation ship with that particular dirver parameters, if in a ported enclosure, then the port parameters, enclosure volume and the particular driver parameters, used properly will get you a desirable frequency response, and so on depending on the particular enclosure type, and the particular subwoofer or driver you're using, by placing it in an enclosure you can change its frequency response, manipulate the level of out put, sound quality characteristics, etc, etc.