Heat pumps move heat from low-temperature sources to higher temperature loads. There are many types of heat pumps, but they all perform this basic thermodynamic mission.
For heating buildings, the low-temperature heat typically comes from outside air, buried earth loops or groundwater. For cooling buildings, the low-grade heat comes from interior air.