In many materials, each electron is paired with another electron that spins in the opposite direction. These paired, opposite spinning electrons end up with their magnetic fields canceling each other out. As a result, these materials have extremely weak magnetic fields.
Other materials, however, have one or more unpaired electrons producing magnetic fields that are not canceled out. That's still not enough to produce a magnet, though. You see the magnetic fields of these electrons usually don't combine unless the arrangement of the atoms is just right. These materials will have weak magnetic fields.
In materials, like the iron nail you used in the experiment, the unpaired electrons make a strong magnetic field. Then the fields of these electrons combine to form what is called a magnetic domain. A magnetic domain is a cluster of many atoms that have their magnetic fields aligned and so act as a magnet. Materials, such as iron, can be magnetized (when exposed to electricity or another strong magnet) because they contain magnetic domains.