Let’s say I have an external HDD with 4 TB of data, and I store it in the shelf.
There is no dust going into it, or anything.
I take it out from the shelf after 10 years, will it work perfectly in theory?
If not, what part can deteriorate and why?
Superparamagnetism is used to “flip” magnetic fields of small particles on drive platters, in order to record data.
https://en.m.wikipedia.org/wiki/Superparamagnetism
There is a slow relaxation over time because sometimes particles flip spontaneously. This means that after a very long time the magnetic patterns on the platters will become more and more random and errors will appear. Error coding, larger regions, and parity and similar tricks can minimize the problem. Higher densities can make it worse.
The rate of relaxation depends on the sizes and density of the magnetic regions, the magnetic properties of the material, external magnetic influence and temperature. If the temperature was absolute zero and no external magnetic fields were present, the magnetic properties of a hdd platter would last forever.
Modern large capacity hdds are filled with helium for cooling and to create a gas cushion between the platters and the reader heads. Since helium is a very small molecule, over time it will leak out through the case of the hdd, making the hdd performance reduced or fail. The helium will slowly leak out, even if the hdd is not being used.
Typically hdds fail early, after less than 10 years, due to vibrations, drops, head crashes, overheating, misalignments and failed electronics. Not because of magnetic relaxation or helium leakage. But eventually magnetic relaxation and helium leakage will cause problems.