Folk often ask “how long will my Mac last & still be relevant?” Well, I bought my 2017 4k iMac (quad-core 3.0 GHz i5) with a dedicated graphics card & 16 GB RAM just six weeks after that model update was released, July 2017. That’s 5 months shy of five years. It’s still going strong, meeting most of my computing needs & has the newest available OS variant installed. One major change made was exchanging the 1.03 TB Fusion drive with a 1 TB SSD.
If I need more capability or speed, I also have an M1 MacBook Air.