They should last a long time, and Apple usually does equip them with durable components. However if they ever do fail, they are much worse than typical desktops to service.
A broken component on a typical desktop represents an upgrade opportunity (HDD/SSD/GPU/NIC/etc). Spend a bit of money for a better component, which will improve performance a bit.
A broken component in an iMac represents an inflection point - spend 50% or more of what your iMac is worth to have it perform as well as it did before said component broke. Yes there are some exceptions (eg. replace HDD with SSD), but even in those situations the maintenance is not for the timid, and labor costs are extreme. Case in point, my late 2012 iMac's stand broke a few weeks ago. While this isn't a huge deal operationally (temporarily fixed by wedging something to hold it firm), eventually I will need to get it fixed. If it wasn't under AppleCare, this would cost me ~$600... for a stand! That's because fixing the stand requires complete disassembly, including the mobo. And, though mine is still covered for a couple months, it will still require me to go 1-2 weeks without my main system.
Point is, these iMacs are designed to be disposable. So, even if something small does break, it can be a big deal.
Always buy AppleCare, for iMacs. While they are somewhat durable, they're not designed to be serviced.