This tradition is a joyous celebration of the arrival of the Three Wise Men (also known as the Three Kings) who brought gifts to baby Jesus. The floats are decorated elaborately and often depict the kings on their journey.
The candy is usually thrown from the floats themselves, or by people participating in the parade, to the children (and adults!) who line the streets. It's a fun and exciting event, and a highlight of the Christmas season in Spain!