Here’s a neat infographic from Compound Interest (one of my favorite websites) that describes 16 different gemstones and why they have different colors. It also includes their chemical formulas and hardness on the Mohs scale.
Many gemstones would be colorless or a different color if not for the presence of small amounts of transition metals such as chromium or titanium. For example, you can see that aquamarine and emerald both have the same chemical formula Be3Al2(SiO3)6, but emeralds are green because of chromium ions replacing some of the aluminum ions and aquamarines are blue because of iron 2+ or 3+ ions replacing some of the aluminum ions. Click through to read the whole article, because there are many other ways that gems and minerals get their colors!