A muffler is a harmonically tuned chamber that is designed to reduce the noise created by the combustion process.
Mufflers are usually designed with specific sound frequencies in mind. When a vehicle is being designed, the engineers will measure the sound frequencies emitted by the engine, and using harmonic tuning, create mufflers that specifically cancel certain frequencies, and amplify others (ie in a sports sedan, you want quite exhaust at low throttle/low RPM, but louder exhaust at high throttle or high RPM).
The image below is a cutout of a typical muffler. You can see the exhaust gasses and sound waves will enter (on the left) and exit (out the top). The baffling allows the exhaust to travel the path of least resistance (once pressure has built), while forcing the sound waves to bounce around through the various tubes and chambers, thus canceling the desired frequencies. The volume of the sound baffling chambers is why mufflers are as large as they are.
If you were to drill a hole in your muffler, the sound waves would be allowed to escape before the baffling has taken full effect, making your exhaust louder. The sound of your drilled exhaust would change based on where you drilled the hole, drilling in one spot might effect the entire rev range, while other spots might only effect the sound at high RPM. Tuners will design mufflers with different baffling/chamber designs to amplify the sound and volume of certain frequencies.