According to legend there was a candy maker who wanted to invent a candy that was a witness to Christ.
First of all, he used a hard candy because Christ is the rock of ages. This hard candy was shaped so that it would resemble a "J" for Jesus or, turned upside down, a shepherd's staff. He made it white to represent the purity of Christ.
Finally a red stripe was added to represent the blood Christ shed for the sins of the world, and thinner red stripes for the stripes He received on our behalf when the Roman soldiers whipped Him. Sometimes a green stripe is added as a reminder that Jesus is a gift from God.
The flavor of the cane is peppermint, which is similar to hyssop. Hyssop is in the mint family and was used in the Old Testament for purification and sacrifice. Jesus is the pure Lamb of God, come to be a sacrifice for the sins of the world.
So, every time you see a candy cane, remember the message of the candy maker: