The specific types of heat pumps we shall be talking about are air to air heat pumps and not ground source heat pumps. Above a temperature of absolute zero heat is present. It is this principle that enables air to air heat pumps to gather heat from the air and then transfer it via refrigerant to commonly a buliding where it can utilised for heating purposes.
Air heat pumps themselves cannot generate heat put its the principle that they can transfer heat from the outside air and transfer heat to the inside, its a fairly simple principle but is one of the most cost effective ways of producing heat. They use the same fundamentals principle as your refrigerator but in reverse, transferring the captured heat in the refrigerant gas and delivering it via the indoor unit to indoors where it is required.
The refrigerant gas is at around minus 28 degrees so relatively if the outside temperature is minus 5 as an example heat can be extracted from the air to the colder body the refrigerant. Think of when you sit on a cold seat your bottom feels cold the reason is that heat transfer is occurring the principle of an air to air heat pump.
The great thing about a heat pump is the ability of it to consume an amount of electricity in its operation which in turn will give you a higher heat output, this is known as the coefficient of performance, shortened to COP. So typically for example a wall mounted heat pump system might consume as its input power 1000 watts and in turn output 3500 watts of heat. You can see from this that typically you can get around 3.5 times the output in relation to the input, hence making them extremely energy efficient devices. Typically most air heat pumps are designed to operate down to an outside air temperature of minus 15 degrees making them very suited to the UK climate.