Answer:
In a material, the magnetic behavior depends on the alignment of magnetic moments of the atoms. Magnetic moments are generated by the motion of the electrons in the atoms. When the magnetic moments of atoms in a material are aligned in a specific pattern, it creates a magnetic field which results in the material being magnetic.
In many materials, the magnetic behavior arises due to the alignment of magnetic domains, which are regions of atoms with magnetic moments aligned in the same direction. When many domains with aligned magnetic moments are present in a material, the material becomes magnetic.
The magnetic behavior of a material depends on the number of electrons and the arrangement of those electrons in the atoms. In particular, for an atom to have a magnetic moment, it must have unpaired electrons, meaning electrons that are not paired with another electron with the opposite spin. When these unpaired electrons in the atoms are aligned, they generate a magnetic moment. If all electrons are paired, there will not be a net magnetic moment, so the material will not be magnetic.
So, in summary, the magnetic behavior of a material is determined by the alignment of magnetic moments of atoms. When the magnetic moments of many atoms in a material align in the same direction, it creates a magnetic field, leading to a material being magnetic. This alignment is usually present in magnetic domains consisting of atoms with unpaired electrons.