According to WebMD, food cravings are related to the parts of the brain associated with memory and pleasure: the hippocampus, insula and caudate. These areas are active during a craving and play a role in the brain's reward mechanism.
WebMD also explains that food cravings are related to emotion. When under stress, an individual may resort to satisfying a craving in order to improve serotonin levels, as high-carbohydrate foods boost this hormone. Fats provide a similar effect. Evolutionarily speaking, cravings may serve a purpose in humankind's survival as a mechanism to combat famine, as excess calories are stored as body fat.