This assumes an understanding of the basic configuration. If that is not the case start here.
The electrostatic field is used to accelerate the electrons and ions.
The magnetic field traps the electrons. The trapped electrons attract ions. The ions form a virtual anode. The electrons form a virtual cathode.
The purpose of the magnetic field is unitary - reduce electron losses. It does this in two ways. Magnetically bottling the electrons. Shielding the anode from electrons.