I still have an original Intel iMac and it runs perfectly, the only thing I've done to it was upgrade the hard drive to 500GB. Although the original hard drive still runs perfectly. I still have some 512MB (Yes, MegaByte) hard drives that still run fine, so hard drives can last a very long time.
In addition, all my old Macs like the Apple ][e and Quadra 650 still run fine. So you really don't have to worry much about Macs not lasting for a long time. And if you are worried then you can always get AppleCare, but I usually only get that for portable computers.