Humans use the energy in food to live; this energy is measured in calories. If people consume lots of calories from food and don’t burn them up, they get converted to fat and stored in the body and so people gain weight. This was very important when humans were not always guaranteed access to food daily. They could use the stored fat in their bodies for energy until they could find food again. If people burn more calories than they consume through food, by doing lots of exercise etc, then their bodies use the fat stores instead and, as a result, they lose weight.
Answered by Kate Mulcahy, Science Museum.