Astronomers are still uncertain as to where our sun's magnetic field comes from.
We know there are magnetic fields in molecular clouds, but trying to determine how these fields shape the forming stars and vice-versa is still an unanswered question. There are many extremely intelligent people working on magnetic fields and star formation, but any answer is still many years, if not decades, away. Sincerely, Kurtis Williams Back to the Ask An Astronomer page.