Background
The Sun is mostly 73% hydrogen, 25% helium, and the remaining 2% is trace amounts of heavier elements like oxygen, carbon, nitrogen, etc. Most of this material is a plasma, which is one of the four fundamental states of matter. A plasma is created by super heating gas, or subjecting gas to magnetic fields, such that the electrons and protons are no longer bound to an atom or molecule. Because electrons and protons are charge particles, they are subject to electromagnetic forces. In fact, it is a good approximation to think of the plasma carrying the magnetic field with it or that the magnetic field is ‘frozen’ into the plasma.
Electric and magnetic fields are important in the convection zone of the Sun, where the plasma is being churned as it cycles towards the photosphere. Since the Sun is rotating, the plasma will also rotate, causing the magnetic fields to wrap and twist on the surface of the Sun. Many features we can observe on the photosphere, chromosphere, and the corona of the Sun are caused by magnetic fields. These features include sunspots, plage, prominence, filament, and granulation.