Magnetic fields arise because of moving charges which is the existence of a current (given by Ampere's law).
Alternatively, a magnetic dipole is set up as a result of a charge moving around in a circular loop. So it follows that magnetism occurs from moving charges moving in different ways.
The magnetic properties of atoms and molecules are primarily dependent on the spin of electrons in a substance. Electrons can spin in one of two opposite directions and any two electrons in the same orbit are constrained to spin in opposing directions. A spinning electron behaves as a small magnet and will produce a magnetic field while orbiting around the nucleus of an atom. The opposing spins of two electrons in an orbital results in a net zero magnetic moment. Diamagnetic substances have zero net magnetic moment because they have the same number of electrons of opposing spin. Diamagnetic substances are actually slightly repelled by a magnetic field due to the negative charge of the electron clouds. Quartz and calcite are diamagnetic.
A paramagnetic substance has a random arrangement of magnetic dipoles of the atoms in its structure until the material is placed within a magnetic field. At that time the dipoles will align themselves with the external magnetic field. Olivine and pyroxene are paramagnetic.
Ferromagnetic substances show strong magnetic attraction when subjected to a magnetic field and will remain magnetic after the removal of the magnetic field unless heated above their Curie temperatures. Magnetism occurs because the magnetic dipoles of domains that make up a ferromagnetic substance align when in the presence of a magnetic field. Metallic iron, nickel, cobalt, and numerous alloys of these, they are ferromagnetic. Heating above the Curie temperature of a ferromagnetic substance causes the magnetic dipoles in the domains to randomly realign and the material will behave as a paramagnetic substance. Ferrimagnetic substances are characterized by strong permanent magnetic susceptibility caused by ionic spin moment that are antiparallel. Magnetite and pyrrhotite are ferrimagnetic.