There are charities that take old electronics to give to people who need them. I don't want to list any here since I'd have to do a background look to see if they're any good, but many come up on searching.
With old phones for example, if it's years beyond OS updates, and hardly any apps in the App/Play stores will work on it, at this point it's really just a collector's item, or garbage. Poorer people don't want non-functional products, either.
This was a bigger thing years ago, but maybe it's not as much anymore. All I could find was Cell Phones For Soldiers.