Transferring heat from the roasting machine to the bean causes a complex series of reactions turning fats to sugars. The caramelization of these sugars gives coffee its color. The longer the coffee is roasted the darker the beans become.