So first as Rob mentions, the gearbox. They can be faulty or they can last. You will not know unless you've had the car for a bit.
Then there's the swirl flaps. Google this. Again, see in my thread for more info. There's a hefty DIY involved to remove them. If you don't, chances of engine failure are high. Basically small metal flaps that control the airflow/fuel mixture ratio for aiding fuel consumption. These are housed in the intake manifold and over time become brittle and can be sucked into the engine.
Vacuum lines, vacuum reservoir/cannister and anything air related will need tending to. These hoses become brittle and you will have endless power loss issues unless you bypass all these lines and replace the one needed most. Again, read my thread.
The DPF will need removing - this is a filter that sits on the exhaust after the turbo. It becomes clogged and will cause strain on the turbo.
Fuel lines tend to leak at this age and will need checking. Fuel pumps likely to fail around 250k km, but may hold out longer. The high pressure pump is a R8k job minimum.
The turbo is guaranteed to need replacement somewhere in the 200k's mileage range. That's R15k without labour, definitely not from BMW.
If you are good with your hands and love to DIY and don't mind getting dirty, then a diesel E39 shouldn't scare you off. But a cheap one, this leads me to believe it has a range of issue, most likely some of the above.
And touching back on suspension, this will definitely need doing. Those engine are heavy as hell.