During times of famine, fat could be used as a source of energy. When there was an abundance of food, people ate an excess of calories, and stored the unused energy as fat. When people were in a caloric deficit, they used the stored fat since they weren't eating enough. This function doesn't help us in modern society, as we are consistently able to access food, and don't have any famines to worry about.