E39 M5 > E55 / E60 M5
I think the E39 is a no brainer
E60 M5 doesn't strike me as a good investment.
Nor the E55, while I like them, their a bit iffy inside and do suffer from some of MB quality issues of the period.
The E39 offers a proper manual gearbox and has a V8 engine sound that soothes the ear, rather than that headache inducing racket the M5 V10 makes.
I suspect the E39 M5 will hold value, if not increase from this point on in, high teens is as low as I've seen them go on average, but most are well into the 20s.