The molecule is
on the left side:
slide the piston inside
without resistance from
Let the molecule push the piston.
Net result:work done on the piston.
We produce useful work by extracting heat from the molecule. However, we need to erase the information about the position of the molecule in order to return to the initial state. This generates entropy, which saves the Second Law of thermodynamics.