What is the function of the thermostatic expansion valve?

Keep the evaporator with sufficient amount of refrigerant to satisfy all the expected thermal load conditions for the refrigeration system, also controlling the evaporation temperature and what we call overheating.