Overview
The longevity of the data stored on any drive depends on the conditions where it is stored and for how long. For hard drives, there are three main factors: magnetic field breakdown, environmental conditions, and mechanical failure.
Magnetic Field Breakdown
Most sources state that permanent magnets lose their magnetic field strength at a rate of 1% per year. Assuming this is valid, after ~69 years, we can assume that half of the sectors in a hard drive would be corrupted (since they all lost half of their strength by this time). Obviously, this is quite a long time, but this risk is easily mitigated - simply re-write the data to the drive. How frequently you need to do this depends on the following two issues (I also go over this in my conclusion).
To periodically refresh the data on the drive, simply transfer it to another location, and re-writing it back to the drive. That way, the magnetic domains in the physical disk surface will be renewed with their original strength (because you just re-wrote the files back to the disk). If you're concerned about filesystem corruption, you can also format the disk before transferring the data back.
You can also help to avoid this issue by archiving your data with recovery data and error correction when you put the data onto the drive. Many archive formats support the inclusion of data recovery algorithms, so even if you have a few corrupted sectors, you can still re-build the lost data.
Environmental Conditions
Some government organizations "sanitize" hard drives by exposing them to a very powerful magnetic field, effectively (and literally) removing the data from the hard drive by "resetting" all of the sectors. Do note that storing a hard drive in, or near the presence of magnetic fields (alternating or static) will severely impact the data stored on the drive.
Geomagnetic storms have been so powerful in some areas that they have actually corrupted hard disks in the past. If you worry about this issue, consider storing your drives in a basement or somewhere heavily insulated from the environment.
Mechanical Failure
Some people mention that they believe that the actual physical motor in the hard drive will fail long before the data on the disk platters degrades significantly. While this is an issue for a hard disk that has been sitting for a long time, if the disk is used once in a while (at least every 3-5 years), this should mitigate this problem.
That being said, I have personally heard of people booting up 10+ year old computers with no problems, the disks working perfectly. I don't believe this issue is much of a concern compared to the previous one, since you should refresh the data periodically regardless. That being said, do be aware that mechanical problems are the primary failure of hard drives (and recovering data off of platters is not a trivial task, especially in the future when it may be difficult to find legacy drives).
Conclusion
Compared to conventional long-term storage mediums (tapes, optical discs), the appeal of hard drives is quite apparent - they are small, easy to move around, have very good transfer rates, switch between computers with ease, and the data lasts for a fairly long time. But, like the two other storage mediums I mentioned, hard drives do not come without their own caveats. So long as you periodically "refresh" the data on the hard drive (and, in turn, ensure the mechanical aspects of the drive itself are still functioning), you should have no problems.
Depending on the priority of the data you've stored, you may want to refresh the hard disk more often. If it is essential data, I would recommend no less then 2 years at maximum. If you can withstand some chance of minor data loss (e.g. a few corrupted sectors here and there), go with 5 years. It doesn't take long to copy the data off the drive, and copy it back.
One thing not considered is the servo tracks and markings. These are written one time at the factory and never again (on modern disks). No amount of re-writes by the user or so-called low-level formatting freshens these. Once they fade, they fade!
It's different with the first stepper motor disks of the 80's. They don't have servo tracks and a low-level format writes ALL of the bits - fresh.
1
A similar question was asked some time ago on Serverfault: http://serverfault.com/questions/51851/does-an-unplugged-hard-drive-used-for-data-archival-deteriorate
– Linker3000 – 2011-05-16T22:00:44.0501I remember reading a quote citing 35-40 years, I'll try to find it and post it for you. – Breakthrough – 2011-07-20T10:36:37.610