The function of the evaporator is to absorb heat from the surrounding air or liquid and transfer it to the refrigerant, causing the refrigerant to evaporate and change from a liquid to a gas. This process cools the air or liquid being circulated through the evaporator, allowing for the cooling or refrigeration of a space or substance.