Conservation of angular momentum GIF.
How is it working? Physicists, please correct me if I have the wording wrong here:
The man and the wheel essentially act as a closed system. An externally-applied torque (the standing man spinning the wheel by hand) produces vertical angular momentum in the wheel. When the wheel is turned horizontal, the man must spin counter to the wheel's rotation, to conserve angular momentum.
One interesting usage is in spacecraft telescopes. Such spacecraft need to be pointed in a very specific direction. If a spacecraft must be rotated by very small amounts, they can do so with an electric motor attached to a flywheel, called a reaction wheel. When the rotation of the spacecraft changes, the reaction wheel is used to counter-rotate the spacecraft proportionally.
Reaction wheel from Kepler spacecraft: