Fermentation has been with us longer than recorded history, most likely going back to Neolithic times. As a process it happens all on its own, such as when fruit becomes overripe or honey is diluted with water. Because the yeasts which work this transformation can be carried over from one batch to the next, it would not have been difficult to begin intentional cultivation of favorable strains. Beer, wine, and leavened breads were among the first uses of yeast. It was not long before local wild yeast cultures were employed to ferment and thus preserve all manner of things.
In the process of fermentation a carbohydrate (sugar for yeast, starch for bacteria) is converted into an alcohol (by yeast) or acid (by bacteria). The two can even work in concert, as seen in a SCOBY (Symbiotic Community Of Bacteria and Yeast) like kefir or kombucha. The yeast produces carbon dioxide in addition to ethyl alcohol, which is what gives beer its foam, champagne its fizz, and bread its rise.