While the variety of candies seems endless, all of them fall into two main categories: crystalline (typically soft and creamy) and non-crystalline (generally hard and brittle). The deciding factor is how the preparation process manipulates the sucrose molecules within sugar. Mmm, crystallization.
The basics of candy making: Sugar is blended with other ingredients and water, and then heated to a desired boiling temperature that will influence the final level of sugar concentration. The mixture then cools, and it is this crucial period that will determine whether your candy is soft as fudge or hard as a lollipop.
As the chemistry blog Compound Interest explains:
The cooling process is actually very important, as it's at this point that crystals of sucrose form. The sucrose molecules can align and form large 'lattices' of molecules, with a regular repeating structure; stirring is avoided until the solution has reached a relatively cool temperature (around 40˚C), otherwise it interferes with and prevents crystal formation. The small, fine crystals of sucrose that are formed give texture – for example, in the case of fudge. They also generally lead to a smooth, creamy candy.
By contrast, in the case of non-crystalline candies, such as lollipops and toffee, we actively want to prevent crystal formation. This can be accomplished in a number of ways. Chemically, "interfering agents" can be added to the sugar solution in order to prevent crystallization— common additions include other sugars such as glucose and fructose, which, having molecules of a different size and shape, get in the way of the sucrose molecules and stop crystals forming. Other chemicals, particularly acids, can be added to break up the sucrose into glucose and fructose, which also prevents crystallization. Other substances can act as "mechanical interfering agents." These include fats and proteins.
The temperature to which non-crystalline candies are heated is generally higher than that for crystalline candies, and they generally contain higher concentrations of sucrose. Once non-crystalline candies have been cooked and cooled, they must be "ripened"—this process involves storing the candy to allow the moisture level to rise slightly and re-dissolve any small crystals that have formed in the sugar solution. The result is a smooth candy, and often hard.
[Infographic: Compound Interest]