Hard drives are a particularly bad example too because the risk of failure goes up as the device ages, so people probably should replace them after a few years of heavy use regardless of software support.
We live in a rich society, electronics are relatively cheap, and people like having shiny new things. We will inevitably continue having more and more electronic waste. Right to repair type laws are great for consumers for many other reasons, but I don’t think they’ll make any kind of meaningful dent in the reduction of electronic waste.