The rough process of the most important steps is:
- Backup the data you want to keep
- Install an open Android OS like Replicant or LineageOS according to the respective guide for your phone
- Install the F-Droid app store
I have some older iPhones and would be interested in reusing them, say, as dedicated webcam servers or similar. It will be a great day when someone comes up with a way of flashing an iPhone with another operating system.