They transfer heat from one location to another. They compress gas, which heats it up. This compressed gas is fed into a radiator effort thing, through which air blows and is warmed up - thus heating the room.
The gas is then allowed to expand again, at which point it cools down significantly. This colder gas is passed through another radiator outside, and ambient air is used to warm it up to outside temperature again. And the cycle is repeated.
The energy cost is in pumping the gas around, NOT in generating the heat, which is simply transferred from one location to another.