I run mine longer than most. I specifically plan not to upgrade for ~5 years. Inevitably, in that amount of time, something arrives that makes a compelling difference to me. The last time was the extensive use of GPUs in my image processing work (I'm a pro photographer). My late-2015 iMac i7/64GB had a weak GPU, which was fine in 2015. But now some of the software needed better. As a result, I have a 2021 14" M1 Max 64GB, which dropped some processing times by about 50x (fifty times, from a couple of minutes per image to a few seconds per image). The M1 Max won't be replaced for a minimum of three more years.
In the meantime, the 2015 iMac has gone downstairs to replace late 2008 Mini running Ubuntu to control my model railroad. The old Mini is teetering on the edge of hardware failure (the fan is starting to make bad noises), so I guess it'll be retired. That's 15 years of use. I expect that the 2015 will run in this application for quite a while; it is massively overpowered for what it's doing, considering that even the old Mini wasn't really sweating. If I run out of security updates on the 2015, it will be moved to Ubuntu also.
The machine that preceded the 2015 was a 2010 iMac i7/24GB, and it too is still going strong. Today it has relaxed duty as a multimedia machine for the home theatre (alongside the Apple TV, a physical BluRay player and - gasp - a turntable), also running Ubuntu. If it fails, which is always possible after 13+ years, it will be replaced by the 2017 i7/16GB MBP, which is still running MacOS.