Ok, lets have a go. CaPtBlaCk has actually managed to post a very comprehensive list of all the problems already so rather than go over old ground I'll hijack his list and expand on some of the stuff.
Firstly a word about 530i v 540i. Before the detractors arrive, these statements are relative - ie, comparing the two, not comparing them with other cars.
The 530i is the precision instrument and the 540i is the sledgehammer.
The 540i offers 55bhp more power and a heap more torque than the 530i. As such, it's ideally suited for effortless wafting with the autobox. This means it's 0.7ish seconds quicker to 60 than a 530i and you don't need to work the engine with the same level of effort as you do with the 530i (Although the 530i is hardly a Honda VTEC!). Thats the benefits.
The downsides of the 540i are all related to the size and weight of the engine. It's big - both physically and in terms of capacity. This means it's quite a hefty old weight in the front of an E39. This has two key effects:
a) The weight distribution of the 540i is not 50/50 as per the 530i, the weight is more front biased
b) The rack and pinnion steering system of the 530i does not fit in the engine bay of the 540i. This means it has recirculating ball steering.
The upshot if this is that the 540i does not handle as well as a 530i, nor is at as well balanced and neither does it have quite as nice steering feel. Oddly this same problem blights the M5 - but to a lesser extent as it has a servotronic steering system - but Pete and Olly both noticed the 530i had sharper steering than the M5.
So - it depends what you want. Wafty torque and effortless performance, or precision handling without quite as much grunt behind it.
I happen to think that the choice of transmission should make this decision for you. If you fancy a wafty auto, buy a 540i. If you want a manual, buy a 530i.
And don't waste your time even thinking about a 535i - it offers the disadvantages of the 540i (handling, balance, fuel consumption) but with the performance of a 530i.
Fuel economy wise, I'd do the maths on 25% more fuel usage than your 330i. You might do a bit better or a bit worse, but use 25% a base for your calculations. It'll do 16-17mpg around town, but then I'd imagine your 330i wont be topping much over 21-22mpg.
So lets move onto the common problems and expand on some of them, add in some estimated costs, etc.
Cooling system inc water pump & valley plate (leak, fail and blow up)
This is the E39's achillies heel. Much per the 330i, the cooling system is horrendous. It all goes wrong. £500 replaces the whole lot.
Cyl-head cover gaskets (leak oil onto spark plugs)
Common on 530i and 540i. Easy job on the 530i, hours labour and 30 quid parts. Bit more involved on a 540i as it's got two of them.
VANOS units on the M62 (knock)
Not quite as common as the cooling system - but
http://www.besiensystems.com can offer VANOS repair solutions. It's very labour intensive work, though.
The aux pusher fan is a common E39 problem. This is the fan thats primary function is to kick in for the AC. It doesnt run all the time - it spins up when the pressure in the AC system reaches a certain level (or, additionally, when the coolant temperature reaches an abnormal level). You can check its working - turn the AC on and wait for a bit. If its broken you'll see it try and spin up and not.
£200-£300.
Chain tensioners (rattle)
Not sure how involved this is, I think its quite a biggy.
Torque convertor (lock up function fails)
Auto-Gearbox (many issues generally related to BMW recommendation of life time oil fill - life time decrypted = 50K change point)
This is a huge can of worms. Half the internet thinks if you dont replace the oil, the gearbox will die. The other half the internet thinks if you do replace the oil, you'll disturb stuff and the gearbox will die.
If the box does go - and it's a pretty significant risk in my opinion - you are looking at one of the few remaining potential 4 figure bills on these cars. Budget £1500.
Crank vent valves & cyclones (fail)
Common one this. Fiddly on the 530i, nightmare on the 540i IIRC because it's in some completely stupid place, I think its in between the V under the engine cover - and not the easy to remove plastic one. The top needs to come apart to get to it?
Water cooled alternators (bearings fail)
Yup - 300ish. Didnt realise it was water cooled though. Mine isn't and I thought it was the same one.
Belt tensioners (noisy/fail)
This is the ribbed V belt for the waterpump, aircon, etc etc. £100ish gets this all replaced.
As with any car really - though the most common one is the nearside rear as the exhuast runs past it and dries it out.
Suspensions arms/bushes various (whole manner of vibrations & noises)
This is the usual cause of the dreaded E39 shimmy - where you feel a constant vibration through the wheel at speed. It's usually worn upper and lower control arm bushings, the best way to fix them is to replace the arms, they are £250 a side + labour I think. Do not use cheap pattern parts, its false economy. The OE is Lemforder - use these.
Dash clocks (pixel failure)
This is a HUGE problem and will affect all 540i's as they all have the High OBC.
A quick lesson in E39 OBC's.
There are two - high and low. Low is found on 6 cylinder cars and comprises of a simple trip computer with mpg, average speed, etc and a pictogram of the car to highlight open doors, broken bulbs.
The high OBC is found on 8 cylinder cars, all cars with the navigation system and cars specified from the factory with high OBC. It has extended functions - two trip computers, speed limiter, etc etc. It is also a dual line text display which displays text messages - ie, 'DRIVERS DOOR OPEN' rather than lighting up on a picture.
There is a design flaw where the pixels randomly die on the display of high OBC cars. Eventually the display is unreadable. It was the subject of a recall in the USA, in the UK BMW just pretended it wasn't a problem.
Cars with high OBC (and some low OBC cars) and no nav have a 'Multi Information Display' for the radio. This is another 2 line display - allows access to radio functions and trip computer functions through the radio unit. It is also affected by the same problem.
There are people who can repair this - they charge £100ish a time though.
Headlights (parts break internally, covers age with reduced light output)
The part that breaks internally is the headlight angle adjuster. There is a repair kit, but as he says the covers age and it ruins the light output. The facelift Angel eye headlights are polycarbonate and a pain to polish.
The practical answer is to buy brand new Hella light clusters. They are £200ish each.
Boot lids rot around number plate fixings/lock & spoiler
This is one of the common E39 rust spots. The other is above the rear bumper at the rear of the gear between the bumper and the tailgate opening. And the other is inside the fuel filler cap - this normally needs a replacement rear wing to fix at huge cost.
Rust is not particularly common elsewhere.
Heater motor resistor (fails, usually plaguing you with an intermittent flat battery months before it is diagnosed)
This is the Final Stage Resitor, or hedgehog. It will cause the climate control system to have a mind of its own, including firing itself up in the middle of the night and killing the battery. The part is £50 and you can DIY it in 20 minutes but all the skin comes off your knuckles.
He's covered most of the bases here, a few extras:
a) Propshaft centre bearing. If it goes CLONK when taking up power, it needs a new one of these. No idea how much it costs as I blagged an entire propshaft under warranty.
b) High Gloss Shadowline goes rusty and bubbles up and ends up looking crap. It's also eye wateringly expensive to replace.
Basically the bottom line with these mechanically is that although there is now little short of a blown engine or a new gearbox that will cost you more than a grand, you will get used to the concept of throwing a few hundred here, a few hundred there, etc etc. It all adds up to probably quite a bit - infact you could run a much newer car with warranty etc for not a huge amount more - but then it wouldn't be an E39, and IMHO, there isnt much quite like an E39.
I still beleive that this car was BMW's finest hour. Newer cars are better because they are newer, not because they are a fundamentally better design, if you see what I mean.