the whole assembly is called an alternator (generator). as
feng125 said, it generates power from your crankshaft's rotations
and charges your bike's vital functions like battery, CDI etc, but
that's after the AC current is converted to DC via the rectifier
(mentioned in another post).
the magnetic part is attached to the crank-shaft, and the wire coil
is stationary. also plays a vital role in spark timing. the
electrical pulse generated is used to "tell" the CDI what position
the piston is in (BDC, TDC, BTDC etc), and the CDI is programmed
accordingly.
as for how to maintain, prevent damages etc, sorry man, i'm not
that pro.. 
------------------
rock hard... ride free...