According to many food historians, hard candies like the candy cane were originally manufactured for medicinal purposes—think: cough drops.
"When sugar first became known in Europe it was a rare and costly commodity, valued mainly for its supposed medicinal qualities and found its place in the pharmacopoeia of the medieval apothecary...Sugar gradually became more widely available in Europe during the Middle Ages. In Britain it was considered to be an excellent remedy for winter colds. It might be eaten in the form of candy crystals...or it might be made into little twisted sticks which were called in Latin penida, later Anglicized to pennets. The tradition of penida survives most clearly in American stick candy which is similarly twisted and flavoured with essences supposed to be effective against colds, such as oil of wintergreen."
Source: Oxford Companion to Food by Alan Davidson