The thermostat in a refrigerator regulates the temperature. It works by switching the cooling system on and off as needed to maintain the set temperature, ensuring a consistent and safe environment for food storage.