I've had my E39 540i for 8+ years. Aside from the usual brakes/tyres/oil I have spent about $800 in total on parts - water pump, fuel pump & filter and a couple of other small things. So virtually nothing in terms of ongoing maintenance costs.
Recommend you make friends with YouTube DIY videos. The above cost would no doubt be doubled or tripled if you took it to a shop for repair work.
Overall it's well worth the money and the E39 is probably the last good 5 series... (before runflats and "optional handling" ?!!)