No "permanent magnet" is completely permanent. Heat, sharp impacts, stray magnetic fields, and age all conspire to rob a magnet of its force. A magnet gets its field when microscopic magnetic areas, called domains, all line up in the same direction. When the domains cooperate, the magnet’s field is the sum of all the microscopic fields in it. If the domains fall into disorder, the individual fields cancel out, leaving the magnet weak.
Very sharp impacts jostle a magnet’s atoms, causing them to realign with respect to one another. In the presence of a strong magnetic field in line with the magnet’s, the atoms will realign in the same direction, strengthening the magnet. Without a strong magnetic field to guide the atoms, they will realign in random directions, weakening the magnet. Most permanent magnets can hold up to being dropped a few times, but it will lose strength from repeated strikes with a hammer.
When you look at a magnet on a table, it appears perfectly still, but in reality its atoms vibrate in random directions. The energy from normal temperatures creates these vibrations. Over several years, the vibrations eventually randomize the magnetic orientations of its domains. Some magnetic materials retain magnetism longer than others. Scientists use qualities such as coercivity and retentivity to measure how well a magnetic material keeps its strength.
Like popcorn popping in a kettle, the moderate random vibrations of atoms at room temperature become more energetic when you turn up the heat. At a certain point, called the Curie temperature, a magnet will lose its strength completely. Not only will a material lose its magnetism, it will no longer be attracted to magnets. Nickel has a Curie temperature of 358 Celsius (676 Fahrenheit); iron's is 770C (1418F). Once the metal cools, its ability to attract magnets returns, though its permanent magnetism becomes weak.
Bar magnets for science class have their north and south poles clearly marked. If you store or stack them with the north poles together, this causes them to lose their magnetism faster than normal. Instead, you want to store them with the north pole of one touching the south pole of another. The magnets will attract each other in this orientation and maintain each other’s fields. You can store horseshoe magnets this way also, or you can put a small piece of iron, called a “keeper,” across the poles to preserve its strength.