Think about an ordindary transformer - it consists of two coils close together - they don't have to be connected (and in the case of an isolating transformer such as that found in a shaver socket, they are not).
An alternating current in one induces a fluctuating magnetic field which induces a current in the other. A dynamo works in the same way, except that the magnetic field fluctuates because the magnet is rotating.
OK, back to the transformer. If you take one half and connect to the mains, you get a current in the other half - without the need for connecting them. So why not put the other half inside the toothbrush? That way, all you need do is bring the tooth brush close enough to the magnetic field in order for current to flow.