Now I am just going to tell you what I have heard. These are just my opinions.
And full disclosure, I own a 5K 27" iMac, late 2015.
If you can, I would go for the 2015 iMac's. From what I have found these seems to very stable, and not suffer from many of the problems previous generations have suffered from.
I have read about several 2014 models suffering from bad display burn-ins (ghosting), in the same style the 15" MacBook Pro Retina from 2012 did.
I have also seen a lot of problems with previous models suffering from weird discolorations, when you look from less than optimal angels (Pre retina iMacs).
For the 27" iMacs from 2017 I have already heard a lot of problems with cooling the internal components, causing performance throttling (The iMac slows down, to be able to cool the components). With the much stronger graphics systems in the 21,5" 4K iMacs from 2017, I suspect they also could suffer from this problem. Something I have read once the 2015 models suffer from.
I have only read about performance throttling on the 27" 2014 iMac, not on the 21,5" iMac 2014.
Whatever you do, get one with pure SSD, they are more expensive yes, but a lot faster. And less likely to break down, from worn out hard drives (fusion or pure classic HDD)
Depending on what you do, memory is a little fluent to advise on. I have a 2013 MacBook Air with only 4 GB ram, which works just fine for everyday tasks. But my main iMac have 16 GB ram, and I wouldn't go lower, but I also do 4K video editing, screencasts and gaming.
To future proof I would consider going for the 16 GB, since the 21,5" can't be upgraded later. And go no lower than 8 GB.