The current answers point into the wrong direction. The right direction, in my opinion, is indicated in the comment of dmckee. 

The problem is with your intuition that high temperature destroys a magnetic field. This is wrong as we can see in numerous experiments.

It is correct, however, that there is a temperature at which the particular mechanism by which a magnetized piece of iron keeps up its magnetic field breaks done. The way iron produces a magnetic field is connected with certain properties of the iron atoms - and it is this property which is lost.

High temperature destroys the mechanism of iron (and some other metals) to keep a magnetic field, not the mechanism by which a moving charge produces a magnetic field.

In the sun the magnetic field is generated by moving charges. In iron the magnetic field is generated by a particular alignment of spin structures in the crystalline structure of the metal. Heat leads to movement of the atoms and destroys this crystalline structure.