i'm going to turn into a nerd, so beware everyone
it was actually created due in part to the 1970s FDA banning of Red No. 2, a heavily used red dye that was used to differentiate red-colored candies (i.e. watermelon and strawberry) eventually found to be unsafe due to the FDA finding that in high doses, it causes malignant tumors in rats. So, companies decided to go to the opposite end of the color wheel, blue. The dye was used to assuage concerned customers as fears of Red No. 2 escalated, and even got approved by the FDA in the early 20th century. The dye is actually made out of blackcap berries (a U.S. native raspberry variety), which are naturally deep purple. And dying the compound made of blackcaps blue would differentiate it from grape candies. Due to blue being a very unused color in candy, it was used in many candy companies.