I'd say a current SSD since there aren't any moving parts, but, that depends on the brand of SSD you have. I've had my 1TB SATA HDD for close to 9 years and it still works. My plan is to get a couple of 512GB SSDs and move the partitions to the new SSDs, zero out the 1TB HDD, and still use it for backups (SMART reports the HDD is still healthy as a horse).
As I said before, it depends on the brand, what you use it for (OS, games, programming, etc.), the pagefile set to the lowest settings (200MB will suffice), and trimming it constantly (Windows 7 and higher, and I believe XP, using the Smart Defrag program, can trim the SSD as well).
Depends on how you define working. If you take a new SSD, load data on it, and store it for 20 years unpowered, it will work fine but it may not retain that data 100%. Flash retention is reset each time you re-write a cell but the duration of the next retention period gets shorter with each rewrite cycle. But after that 20 years, it will still have much of the original endurance just not the long term retention.
But similarly, if you put the hard drive on a shelf un-powered, entropy will still win-out with respect to the viscosity of the bearing lubricant. However, without the heat and start-up stresses, it will happen much slower. I suspect even modern drives will retain data for several decades.
Of course the best long term storage is an active solution with constant verification checks - in several physical locations on different mediums.
A third option I've been considering is service based cold-storage like Amazon Glacier. I already do back-ups of critical data (code repos, etc) there as an additional off-site fail-safe. But it might be the most ideal back-up solution.
I'd be utterly shocked if any equipment from the last 20 years is still functional 20 years from now. They pretty much don't make things to last anymore. I'd honestly expect my PDP-11 to outlast either.
They didn't build things in the past that depended on a few electrons hanging around in a floating gate.
Old EPROMs had much larger gates, and even those suffer from bit rot.
Today, flash storage is hidden all over the place inside of systems. A FPGA is the extreme example.
There are fuses hidden inside chips that are programmed on the chip tester when they're made, never to be touched again.
I tell people who come by the museum and ask me how many computers can be made to work in 100 years,
and I tell them almost none made after about 1980.
I've also been telling people inside that we really need to go through and dump every disk and everything that is
programmable inside of the machines in the collection before the bits rot.
Most processors are designed to have a half life of 10 years running. Most storage media is designed to also have a half life of 10 years storage. If you expect to recover something after 10 years, about the only thing I can think of is paper tape. Even there you want redundancy. Redundancy is the key the first key to long term storage and periodic refreshing is the other.
I have a ST506 disk drive that still starts up and read/writes data. I have two others there for backup with the same data on them.
One never knows how long these will last but I expect time will eventually cause these to fail.
It's largely a matter of density in my view. I see no reason why a half-inch magnetic tape recorded at 556 BPI shouldn't retain its content for 75 years, if stored properly. Similarly, I'd expect more longevity for information stored on SLC NOR flash than on MLC NAND. It isn't a hard-and-fast rule, but it's very often the case that higher densities mean less permanence.
An SSD will last longer than an HD unless you're constantly subjecting it to write-heavy loads. Then the HD would probably last longer. But don't count on either being around in 20 years, unless you write data to the SSD, then remove it and put it into storage.