When you first put the nail near the iron filings, nothing happened. After you rubbed the nail with the magnet, the nail picked up the iron filings. The magnet's field makes the moving parts that make up the nail line up and move in the same direction. This makes the nail acquire magnetic behaviors, just like the magnet. If you try to use the nail as a magnet later, it will no longer be magnetic. The nail's moving parts have fallen back out of alignment. Some magnets are permanently magnetic, while others are temporary.