It is not so much the snot which is green as the phlegm component, and this is only when it is infected. Healthy phlegm is not really green.
The phlegm becomes green in the presence of infection (bacteria) due to the large numbers of white blood cells present, which make their way through the airway walls to combat the infection. White blood cells also give pus a whitish-green color, so you'd think mucus would be white but it's snot. (Get it? Sorry, but I couldn't resist.)
There's more to it. Many of the common bacteria associated with humans have color. Staphylococcus aureus is a golden yellow, and Pseudomonas pyocyanea is a shade of blue. The green color of snot comes from the mixture of the yellow and blue. Interesting, yet gross, and hopefully inspirational to stay vigilant about not catching a cold as this snotty season slowly comes to an end.