A fermentation lock is a device used when fermenting a liquid in order to produce alcohol. Yeast can digest either aerobically or anaerobically; aerobic respiration creates carbon dioxide and water as waste, and anaerobic respiration creates carbon dioxide and ethanol as waste. The fermentation lock allows the creation over time of an anaerobic environment in your airtight fermentation vessel. Once the yeast cells become active, they will consume the dissolved oxygen in the wort (or whatever it is you are fermenting) for a time. Yeast activity will create more gas inside the vessel. This gas escapes through the fermentation lock, which is effectively a valve that will not allow outside air to enter the vessel. Thus after a while, the yeast will totally consume all available oxygen and begin creating alcohol.
Most fermentation locks operate by allowing the gas inside a fermentation vessel to bubble through a small container of fluid (water, cheap vodka, or sanitizer). This device is secured to a hole in the lid or stopper of the carboy, bucket, or what-have-you. When the pressure inside the vessel passes atmospheric pressure, the gas bubbles out. This has the happy side effect of making yeast activity very visible.