Everything has a natural frequency. That is why when you blow over a bottle in a certain way it hums.
Music is made up of lots of different frequencies. Notes are not perfect sine waves, they are made up of harmonics. This means that speakers are forced to vibrate at many different frequencies. When the speaker plays at it’s natural frequency, the sound is louder because the sound waves are forced to have a much larger amplitude at this natural frequency. However speakers are damped with foam or other insulation to stop this difference in volume.
The box around a speaker is necessary to stop bass notes from diffracting around the speaker and interfering with itself- cancelling out the bass sounds.