Enzymes are biological catalysts. That is, they are proteins produced in living organisms that help chemical reactions along. Without enzymes, the chemical reactions in your body would not proceed fast enough to keep you alive. Every enzyme has optimal operating conditions -- the environment that allows them to work at maximum efficiency. One of the most important environmental parameters that influences enzyme activity is the pH, with each enzyme having a unique optimum value.
Enzymes work by lowering the activation energy of a chemical reaction. You can think of a chemical reaction as something like putting a beanbag into a bucket, except that there's a 10-foot wall between the beanbag and the bucket. You can climb over the wall and put the beanbag in the bucket, but if you had the help of an enzyme, the wall would only be 2 feet high instead of 10 or 100 or 1000. The final result is the same no matter how high the wall is, but you'll be able to put a lot more beanbags in buckets if the wall is low. The same with enzymes: the final chemical product is the same with or without an enzyme, but many more reactions will happen if the enzyme is there.
We think of pH as a measure of acidity, which it is. Vinegar is slightly acidic, so it has a pH of about 4, while baking soda is basic and has a pH of about 8. A neutral solution -- neither acidic nor basic -- has a pH of 7.
On a molecular level, pH can be though of slightly differently. A low pH means there are a lot of extra protons in a solution, while a high pH means there are a lot of hydroxide ions -- oxygen and hydrogen together. At low pH, the positive charges of the protons in the solution will be attracted to regions with negative charge, and they'll latch on. At high pH, the OH ions, which are negative, will seek out positive charge and latch on.
Enzymes are complicated proteins that bring component atoms or molecules together in just the right way to lower the activation energy. They're able to do this because of how they're shaped. The shape of a protein depends in part on electrostatic attraction between its different parts. For example, some parts have a slightly negative charge, and some slightly positive, so those regions of the protein are bent toward each other.
In solutions of low pH, the extra positive charges connect to negative regions of proteins. In high pH solutions, the extra negative charges latch on to a protein's positive regions. When they latch on, the electrostatic attraction is eliminated and the protein changes shape. Because an enzyme's activity depends upon its shape, it will slow down, then eventually stop working when the pH gets too low or too high.
Enzyme Activity vs. pH
Different enzymes function in regions with distinct pH. Stomach enzymes, for example, work best at a low pH of about 2. But regardless of the specific value of pH where an enzyme works best, enzyme activity is low at the lowest pH and increases to a maximum at the optimum value of pH. The reaction rate then decreases as the pH rises. Within a narrow range around the optimum, the enzyme can recover its activity if the pH is returned to optimum. But outside of that range, the shape of the enzyme will be so distorted that it can't return to normal.