From the wild-colored berries in your local produce section to the breathtaking reds and violets of autumn, anthocyanin is the pigment most often responsible for giving plants colors in the spectrum between red and blue. This pigment is notable for both the way it takes part in leaf metabolism as winter approaches, and the sundry ways that it is useful to man.
As summer turns to autumn, trees begin to save up all the nutrients they can in their wood, and discard those elements which are either very common in the environment or too expensive (in terms of energy) to store. Part of this process, known as senescence, stops the flow of chemicals needed for photosynthesis from entering the leaves. This makes sense, as the sun is getting further from the given hemisphere, so even if leaves could survive being frozen the amount of energy they create in photosynthesis would not be as much as that expended in keeping them vital. This blockade causes the metabolic pathways used in photosynthesis break down, and different parts of them become available to take part in producing anthocyanin. Thus, over the course of a few months, less and less chlorophyll is created and used, while more and more anthocyanin builds up in the leaves.
Anthocyanin is stored in the vacuoles of leaves, which serve primarily as a storage place for water. Since it is not kept in the plant's cells, and especially not its chloroplasts, anthocyanin is not at all involved with photosynthesis proper. Instead, it is the chemical's color itself which has a role in leaf metabolism, rather than any of its chemical properties.
One theory says that it acts to protect the leaves (as they become fragile during senescence) from UV damage by absorbing particular wavelengths of light -- with vacuoles located above cells with the highest concentration of chloroplasts, this makes some sense. Another guess is that anthocyanin works to slow down photosynthesis by reflecting the wavelengths of light that are best used by it; leaves are only green because they absorb the non-green sections of the spectrum. Slowed photosynthesis would theoretically benefit the plant by using less of its energy to produce more energy, which because of senescence wouldn't be able to escape from the leaf anyway. One final finding is that anthocyanin light absorption helps stop photoinhibition within the leaves. Photoinhibition occurs when leaf metabolism is slowed or stopped due to high-intensity light hitting leaves which are already damaged -- i.e. leaves which have survived a frost or two and still need to complete vital metabolic steps.
Besides its role in leaves, anthocyanin shows up in fruits and vegetables, lending some of them their attractive coloration. It is actually the pH level of the surrounding water which decides anthocyanin's color, from perfect red at pH < 3, to violet around 7, up to completely blue at pH > 11. Hence, strawberries, tomatoes, and other acidic fruits have a red coloration; neutral plants like red cabbage and grapes are more purple; and basic plants (of which there are comparatively few), such as blueberries, are blue. Some plants do use other colorings, though, like beets, which are red due to a pigment called betalin. Anthocyanin is responsible for the coloration of red wine, and acidification is why wine ages from red-violet to brick red. Notably, a ghetto form of universal indicator can be made by boiling the pigment out of red cabbage -- the color when reacted with an unknown substance can give hints to its acidity.
Finally, some studies seem to show that anthocyanin has health benefits when consumed in reasonable amounts. Neurogenesis in the hippocampus (the only part of the brain able to grow new neurons) is upregulated in rats when they are fed the equivalent of a cup of blueberries per day. This leads to "better memory", exemplified by the rats doing 50% better in repeated maze trials than a control group. Also, the chemical has antioxidant properties and seems to protect against colon and other cancers. Anthocyanin may be responsible for the health benefits of a glass or two of wine per day, as popularized a few years ago by the press.
For reference, here is a table (generated from a chart, so probably quite inaccurate) of anthocyanin content of different fruits and berries, measured by mg / kg:
(The secret messge of this table is EAT MORE BLUEBERRIES!)