On Mastodon, I just stumbled upon Open Android Installer, which makes it easier to install a community-driven operating system on your Android mobile. I've run LineageOS on an old OnePlus One with great success myself, until I put my big ass on it and part of the screen's touch functionality stopped working. However, it still works as a test unit, here 10 years after the model came on the market. :-)

Disclaimer: Using OpenAndroidInstaller is not entirely without risk of bricking your phone so that it does not work, so everything below is of course at your own risk. My advice is to try it out on an old mobile before you jump into something wilder. Other than that: Good luck with the experiments!
Better manufacturer support, but…

To be fair, mobile manufacturers' support has improved significantly over the years, but they still have the attention span of a 2-year-old (because profits), and either drop or throttle their focus on old mobile devices when they release new ones, so it varies a share how many software updates you can expect to receive. It is a gigantic waste of resources that they force you to buy a new phone without there being a real need - it goes without saying that the planet cannot bear that pressure.
Unpatched, old mobiles are a security risk

There is certainly also a security aspect: any unpatched mobile potentially carries a risk of being part of a botnet that could, for example, aim to bring Internet servers to their knees by overloading them with traffic (DDOS attacks). If that's not incentive enough to keep a mobile up to date, what is?

I understand that you as themanufacturer, might not think it's funny to write code that keeps a toad-old mobile phone up to date, but as the world situation looks like today, with geopolitical tensions everywhere, it's necessary. Ideally, security patches were just something you got automatically, on a daily basis, just like on Linux and the BSDs. Although the Android kernel is a heavily modified Linux kernel, you can't just slap a security patch intended for Linux on it, unfortunately. However, it appears that Google is working on solving within a number of years, by bringing Android closer to the mainline Linux kernel.
Halløj, service economy

We are steadily moving towards the total dominance of the service economy, where we pay for everything via subscriptions (don't think I'm a fan, because it just means that there are more things that you get to rent the "right of use" for...). So if you insist that it is the mobile manufacturer that should be responsible for your phone's updates, then it should be possible to take out some kind of insurance to get updates for the entire life of your phone, if a manufacturer does not provide the service by itself.
The open source community is picking up

LineageOS is an example of an actively developed mobile operating system powered and maintained by the open source community. The OS originates from Google's own Android Open Source Project, so you get the experience of Android as you know it, but without Google's apps as standard - you should, however, still choose to install GApps, such as Google Play Services on top, since the Danish state builds a large part of its IT infrastructure on the technology of the IT mammoth, so in order not to stand with your hair in the mailbox in relation to, for example, MitID and the Rejsekort app, you can hardly avoid Google Play/Google Play Services.

Maybe one day we will be able to buy more pure Linux mobiles with unlocked bootloaders á la PinePhone, but until then this is the best solution.

Link:
https://openandroidinstaller.org/

Level 9000: Real Linux on your mobile

If you are ready for a real Linux experience, you can actually install the real thing on your phone (see the overview on the mentioned websites if it is supported):
Ubuntu Touch, with the same type of installer, or if you're ready to go full hardcore: PostmarketOS. However, be aware that the MitID app probably does not work, nor with Anbox (Android emulator). However, you can order a code viewer from MitID as an alternative to using a mobile phone. I've been having a blast running the Wayland Weston compositor on an ancient Samsung S3 Mini. I recorded a video clip of the boot sequence which I will see if I can find again. It gives me a kick to be able to revive old hardware like that.