I'm not sure it's reasonable to expect any computer to never fail.
It's approximately doable
[1], but it'll be a very expensive computer with all the performance you'd expect of a machine from the 1990s, and will likely run VxWorks or something as an OS.
The compromises we accept for a desktop PC are very different from those for a flight computer on a trip to Pluto. Performance, reliability, cost and presence of various substances are all part of that.
If you really need an iMac not to fail, your best bet is to buy two iMacs, put one on the shelf, and keep some money aside to buy/repair iMacs in future. This will cost a lot more than a single iMac, but should be good enough for most purposes.
[1] At least for small values of 'never'