Using a search engine online should answer the question, if your question is actually "How is a magnetic field created?" From http://www.howmagnetswork.com/

How is a magnetic field created?
When current flows in a wire, a magnetic field is created around the wire. From this it has been inferred that magnetic fields are produced by the motion of electrical charges.

But what most people want to know is how does a magnet attract certain metals? Or, how does a magnet attract or repel another magnet? What is happening in the space between magnets that causes them to act as they do?