Google would need to make it a requirement for bundling their services. Since the major distributers are utterly dependent on Google/Android, they'd do it.
Making it a legal requirement would be challenging, but making it a de facto requirement for all major phone vendors is easy.
Even when going with official Google phones: my Nexus 5 is way out of date OS-wise.
Is it? Slower than on more recent ones I agree. But processors architecture and components has not changed a lot.
If Microsoft manages 10 years on wildly more diverse hardware with their OS, I don't see why it is not possible on official Google phones.
An added benefit of that is a removal of the manufacturer's bloat ware and the ability to compile things yourself, allowing you to modify everything.
If there's no good unofficial/open source software for the device, don't buy it or you're going to be miserable in 0-2 years.