The vast majority of beer is force carbonated, which means its fizz comes from literally jamming carbon dioxide into it—where it stays until it escapes when you pour it into a glass (and again later, right before you say excuse me). Many smaller and traditional breweries, however, rely on a low-tech process called bottle conditioning to create bubbles.
Throughout much of history, beer was consumed essentially flat, with a very small amount of carbon dioxide in the solution. When modern barrels were developed, it was found that they could hold beer with some amount of carbonation present. If you’ve ever been to a bar or brewpub where they offer a beer “on cask,” it comes to you with about as much carbonation as historical barrels would have been able to hold.
With the advent of the bottle, however, new possibilities opened up for fizz. When yeast eats up sugar during the brewing process, it produces two glorious byproducts: alcohol and carbon dioxide: That carbon dioxide is allowed to escape. When making a bottle-conditioned beer, however, the brewer will add a bit of sugar just before bottling. This encourages the fermentation to continue just a bit inside the enclosed bottle, producing a small amount of additional alcohol and enough CO2 to carbonate the beer. Failure to be precise with the sugar measurement can lead to flat beer, over-carbonated beer gushing out upon opening or even bottles bursting on the shelf.