But what is the purpose of that magnetic field?
The goal of the magnetic field is to prevent erosion of the engine itself due to the plumes of the exhaust gas. This is often referred to as "magnetic confinement."
In "HIPER: A HIGH POWER 20KW HALL EFFECT THRUSTER FOR EXPLORATION", a conference paper by Zurbach et al. 2010, the authors discuss many of the design requirements of a 20kW thruster. At the bottom of page 6, they specifically discuss how to implement this confinement in such a way that the temperatures do not surpass the Curie temperature of the magnetic material used.
I thought I had a 2016 SNECMA/Safran conference paper lying around which showed the damage of erosion on a Hall effect thruster they were working on (part of their PPS series) but I can't seem to find it right now. I'll add that information if I do find it.
The electrons emitted by the hollow cathode are accelerated towards the anode, i.e. the positive grids. The magnetic field forces the electrons onto a helical path (additional circular motion), which is much longer than a straight one. By this, the electrons are more likely to collide with the neutral background gas, which is a necessity to sustain a plasma (electron-impact ionization).