Bottles are colored for three reasons, the first two of which are intentional. Dark-colored bottles protect the contents from light. Brightly colored bottles catch the eye, and hopefully lure the buyer to these contents instead of the contents of a competitor. Finally, the sand melted down for glass usually contains various metals that affect which light spectrums will pass through the bottle and which won't.
Following is a tutorial on what metals I believe cause various bottles to have the colors they do. I haven't seen any real chemistry articles on this subject, so I'm going off what I've learned in discussions with other collectors.
The individual photos connected to the article are better quality, and have a caption giving the color designation of each bottle shown.
Grass Green - This is the color of a 7-up bottle. A handmade medicine in this color is generally more collectable that other colors. Old capers bottles in this color are really neat.
Cobalt Blue - To make a bottle this deep shade of blue, cobalt was added. It was a popular color during the early 20th century for medicines and cosmetics. Occasionally an old blob top soda or hand-made medicine pops up, but these are quite rare.
Brown - Iron and sulfur added to the glass will give this color. It was popular for all sorts of beers, whiskeys and bitters bottles. It's a bit more unusual color for medicines or fruit jars, imparting desirability in some cases.
Teal - A common color for fruit jars, teal also shows up in old blob-top sodas and some medicines. Except for the fruit jars, teal color gives a bottle added desirability. There are actually two shades depending on the blue-green mix: teal green, and teal blue.
Olive - This is a natural color of much glass, and happens when there is naturally-occurring iron in the sand used to make the glass. It's a common color for old beer and gin bottles.
Black Glass - Many extremely dark olive bottles can legitimately be called black glass. There are, however also bottles out there (many of them imported from Europe prior to 1880 or so) that are truly black. I assume extra iron was added to glass to make it black, but it's entirely possible that some poor-quality glass sand had naturally high levels of iron.
Aqua - The classic color of old medicine bottles, aqua is often lumped in with ice blue and light green. These 3 are in fact distinctly different colors. Both light green and aqua are natural colors, reportedly coming from low levels of iron in the glass.
Ice Blue - It's my understanding that copper was added to glass to make it this light blue. The first hand-made Milk of Magnesia bottles were made in this color (before they changed over to cobalt blue). Fruit jars are commonly found in ice blue.
Light Green - Food bottles are often found in this color. It's also pretty common for old sodas and beers.
Dark Red - Red bottles are probably not very old. There are two reasons for this. Red can be imparted by adding gold to the molten glass. Of course that was very impractical. It was well into the 20th century before Blenko glass company in West Virginia developed a commercially viable way to produce red glass.
Amethyst - Manganese was once added to the glass to make it clear, but over several decades of exposure to the sun, the bottle turns more and more purple. Among many collectors, sun-colored glass is very desirable, and this has generated a lot of fakes.*
Bottles in the evening sun.
Amber - Few bottles are seen in this rare color. Many brown bottles are called amber by their owners, but true amber is very light - a really beautiful color (something you can't really say about brown). Cadmium, sulfur, silver - even coal additives can make glass amber.
Milk glass - By adding tin or calcium to glass, you can make it an opaque white. This is a typical color for many cosmetic bottles.
Other light colors - My personal collection of old bottles has one yellow bottle and one apple green. "Vaseline glass" contains slight amounts of uranium, which imparts a fluorescent green color. The process has been known since the mid-1800s, but I've yet to see old bottles in this color.
Bottles in the evening sun.
* I'll resist being too judgmental about turning bottles purple using artificial light, as long as the buyer knows it's not natural color. If you like sun coloring, stick to buying bottles that are a light amethyst, because the counterfeits tend to be a beautiful but telltale dark purple. Insulators are an exception to the rule, because they are so thick and did literally spend decades in the open sunshine. If you yourself are making bottles purple with artificial light, I caution you not to do it to a valuable bottle, because the really serious collectors won't buy it if they think it's been tampered with, and some may get really upset.