The blue/green discoloration in your pickled garlic is due to a reaction between sulfur compounds in the garlic and copper (or sometimes iron) in the water or pickling spices. The garlic is generally safe to eat.
Garlic contains sulfur-containing amino acids. When these amino acids are exposed to acid (like vinegar in pickling brine) and trace amounts of copper or iron, they can react to form blue or green pigments. This reaction is more likely to occur in young garlic or garlic that has been stored for a long time, as these tend to have higher concentrations of the reactive compounds. The copper can come from your water supply, the pickling spices you used, or even the pot you used to heat the brine. While the color change is unappetizing to some, the resulting compounds are not known to be harmful in the small quantities present in pickled garlic. The color change doesn't significantly affect the flavor, although some people report a slightly metallic taste.
To minimize the chance of garlic turning blue or green, use distilled water for your pickling brine, avoid using copper or iron pots, and use fresh, high-quality garlic. You can also blanch the garlic cloves in boiling water for a minute or two before pickling; this can help deactivate the enzymes responsible for the color change.