Can you create a heat engine which extracts heat and converts it all to useful work?
This possibility is forbidden and there is even a Law of Physics dealing with it: the Second Law of Thermodynamics.
This law tells us (basically) that it is not possible to build a heat engine where the ONLY result of its operation is the transformation of heat entirely into work (something else must happen as well).
Some of the heat extracted by the engine has to be "wasted" into the environment.
Consider, as an example, a steam engine; some of the heat is "dumped" into the atmosphere as smoke (from the chimney).
This idea of impossibility is at the core of another very interesting (albeit dangerously weird) idea: Entropy.
When you operate your engine you extract “good” heat from a reservoir transforming it partially into useful work and discarding energy that will become unusable and will end up increasing the Entropy of the univers (as a kind of deposit of “bad”, unusable energy).