In a few years, the hard drive may deteriorate and then I will have to throw away the MacBook.
How many is "a few"?
All flash memory is write / erase cycle limited. Apple does not publish that specification, so it is unknown, but failures resulting from reaching that limit are — literally — unheard of. As in zero.
Premature failures prior to reaching that limit are — extremely — rare.
Exactly none of my Macs purchased in the past decade and a half use hard disk drives. They all use SSDs or built-in storage. Zero failures. The oldest ones are functionally obsolete by now, so it wasn't hardware failure that did them in. It's the passage of time and advances in technology that makes Macs obsolete. The same can be said of nearly anything more complicated than a claw hammer.
Nothing in the physical realm lasts for eternity though, so whatever that Mac's ultimate demise may be, it won't be that.
Having said that I strongly suggest you familiarize yourself with lobsterghost1's User Tip The All Too Common SAD Reality of Buying a Used iPad/iPhone - Apple Community. Although it is obviously written for iOS devices, its principles apply equally to Macs.
Some senior ASC contributors whose opinions I respect will advise "never buy a used Mac". I stop short of making such an overarching statement, but the more I learn about problems people encounter with Macs that have not been properly prepared for sale the more I tend to agree with it. Those problems are very common, and sometimes insurmountable. In many cases the hapless purchaser is left with a Mac that cannot be used or returned for a refund. Don't buy a used Mac.