As long as you don't put a newer operating system (or newer versions of apps) on it that introduces some seldom-asked-for-useless-feature-that-slows-the-whole-system-down then it should remain at close to the original performance until something breaks.
I get a new machine to swap out about every 8 years, but I'm actually buying one every 4 as I buy one for business (the smaller one for putting in a backpack & travelling) in year 1, then a home one (27" iMac or MacPro) in year 5, then a business one in year 9, etc.
My current 'old' machine was the 'top-spec' one available at the time...a late 2014 27" 5k iMac with a 4ghz quad-core i7, 32gb RAM and a 1TB SATA SSD (Geekbench 4 scores of 4740/15489). It's still my main machine when I'm working from home.
When I'm travelling I take my smaller, newer, faster 2019 21.5" 4k iMac with a 3.2ghz hex-core i7, 32gb RAM and a 1TB PCIE SSD which absolutely flies (Geekbench 4 scores 5855/27121) - but in day to day use, the think I notice the most is the speed of opening 2gb InDesign files on the PCIE SSD vs the SATA SSD in the older machine.
The 'portable' iMac it replaced (a late 2009 21.5" iMac with only a dual-core 3.6ghz i5 and 16gb RAM - GB4 score of 2703/5371) has gone to my neice. As long as something is not broken, they are just passed down to family members who don't need the fastest processors for their facebook games and general browsing habits. If that had been available with the quad-core i7 from the 27" model, I'd have bought that instead.
I only notice my older machines slowing down when Adobe/Microsoft/Quark introduces their latest version of their software that doubles in size even though they've only added a tiny new feature. This then forces you to either upgrade your machine, or do without the new feature. For example I stayed on Office 2010 and Adobe CC 2013 until this year when I went to Catalina - as neither would work properly. Then realised how slow both of the new versions seemed on the same hardware.
My file sizes increase all the time as clients want higher resolution, larger images and more interactive media in their digital copies of their magazines, etc.
Maybe some programmers feel they can be a bit lazy with their coding and leave a bit extra in there when the performance of the newer machines has got enough headroom to make the effects of the bloat of their sloppy coding disappear.