This device, called a thermostat, is also used in freezers, ovens, air conditioners, oil and gas boiler furnaces, and hot water cylinder heating elements. Its function is to control temperature and keep it at the desired level.
The device consists of a bi-metallic strip of two metals attached together. As temperature changes, the metals which have different coefficients of thermal expansion, expand by different amounts. This causes the strip to bow or bend outwards and activates switch contacts when the temperature reaches a preset level. In the case of a heating appliance such as an oven, a thermostat turns off power to the oven when the temperature reaches the setpoint temperature and turns it back on when the temperature falls to a lower setpoint. There's usually a narrow band of several degrees between the upper and lower setpoints known as hysteresis. Without this, the thermostat would continually cycle on and off with tiny variations in temperature, shortening the life of the switch contacts.