The first recorded 'candy stick' comes from 1837 at an exhibition in Massachusetts in the USA. They started as straight white sugar sticks and a few years later the red stripes were added. The first time they are documented as being called 'candy canes' comes in 1866; and their first connection to Christmas comes from 1874. Early recipes had them as simply 'sugar' flavored. But we're now used to them being flavored with peppermint or wintergreen.
Around 1920, Bob McCormack, from Georgia, USA, started making canes for his friends and family. They became more and more popular and he started his own business called Bob's Candies. Bob McCormack's brother-in-law, Gregory Harding Keller, who was a Catholic priest, invented the 'Keller Machine' that made turning straight candy sticks into curved candy canes automatically! In 2005, Bob's Candies was bought by Farley and Sathers but they still make candy canes!
A story, that's rather nice but probably isn't true, says that German a choirmaster, in 1670, was worried about the children sitting quietly all through the long Christmas nativity service. So he gave them something to eat to keep them quiet! As he wanted to remind them of Christmas, he made them into a 'J' shape like a shepherds crook, to remind them of the shepards that visited the baby Jesus at the first Christmas.
Sometimes other Christian meanings are giving to the parts of the canes. The 'J' can also mean Jesus. The white of the cane can represent the purity of Jesus Christ and the red stripes are for the blood he shed when he died on the cross. The peppermint flavor can represent the hyssop plant that was used for purifying in the Bible. However, all of these meanings were added to Candy Canes after they had become popular.