Thermostats are devices used to control the temperature within a space by regulating the heating or cooling system. They sense the current temperature and adjust the HVAC system accordingly to maintain the desired temperature set by the user.