Maybe 20 years ago and before, devices were made obsolete so fast that it would not have made sense to try to extend the live of hardware but it's no longer the case. Old phones and tablets are perfectly fine for a lot of use cases, they took a lot of natural resources to build and they can only collect dust in drawers or fill landfills now. Finally we are realising that the Earth has finite resources and we should try to make the most of what we have.
Increasing the life of existing IT devices by not withholding informations would be a good first step.
The nice part about such a law, is that companies that want to keep their stuff private would have a way to do so: just keep supporting the devices. If it's not worth supporting, you should not be allowed to keep the IP closed if that prevent the devices from being useful.