The heatpipe is a tube sealed at both ends and partially filled with a heat sensitive liquid. Maybe alchohol with water or some other chemical that evaperates easily.
When liquid evaperates it requires energy. This energy is heat. It heats up, evaporates and takes energy away in order to do it.
Then the steam moves to the colder part of the tube, the steam now attempts to liquidefy again. In order to do this it must get rid of the heat. The tube is cooler then the steam so it extracts the heat energy from the stream and the steam turns into liquid and then the droplets go back down to the hot part of the tube and repeats the proccess over and over again.
Liquid sits in the hot part of the tube, near the heatsource. It heats up, floats to the cold part as steam, the part with the fins and the fan and such. Deposites the heat and then drips back down.
The fins and fans keep the cool part cool, and the heatsink and cpu keep the hot part hot.