That's an interesting question. I searched
wikipedia for that and found the answer. The existence of the magnetic feild seems to hidden in the formation of the magnetar. Still its all fuzzy inside my head.
I would like to extend the question to include Black Holes. Black Holes have degenerate matter of infinite density. Not regular matter of electron (that gives the characteristic of magnetic feild) and protons. They too have
magnetic field. Where the magnetic field here come from?