The magnetism in a magnet is mainly due to:
Electrons have a property called spin. This spinning creates a magnetic field with N and S poles, just as the spinning Earth has magnetic poles.
If electrons in the shells of an atom spin in the same direction, the atom will exhibit a magnetic field and will respond to the forces of a magnet. If half of the electrons spin one way and the rest spin the other way, they will neutralize each other and the material will not be affected by a magnetic field.