Believe it or not, the reason there isn't more purple in flags is primarily due to sea snails.
By the 19th century, the only way to produce purple dye was from an esoteric species of sea snails found only in a small part of the Mediterranean. It took 10,000 of these snails to produce just a single gram of dye.