I sub is put into a box because when the woofer throws, it creates a sound wave when going forward and the exact (so close, we will call it the same) reverse sound wave when returning to its original position. When the sub is in a box, the box absorbs the reverse sound wave so that you only hear the outside sound wave.
Now, when you go to a free air sub. The reverse sound waves travels around the sub and nearly cancels out the front sound wave, thus making no sound.
When you go to ported, there are certain specifications for every sub on port length and diameter. This length and diameter aide in a "time delay" of a few micro seconds so that when the reversed wave from inside the box exits the ports, just enough time has elasped that it has now reversed and now matches the front sound wave coming from the front (outside) of the subwoofer.
Think of ocean waves, if 2 exact waves traveling towards each other collide, they cancel each other out. If one is absorbed (in a box), the other continues and travels. If the 2nd wave was "turned around" (send back through a pre-determined port size) it may turn out to be bigger wave.
Maybe that helped shed some light...