BMW has had it's share of problems. The E34 5-series can be terrible cars to own. They have lots of electrical glitches, problems with suspension bits, failing automatics, defective V-8 engines, among other things. BMW changed the 5-series from a "driver's" basic sedan into a luxury car loaded with complex electrical accessories.
The E36 was a very reliable car, but had numerous oil leak problems, some of which BMW played the "head in the sand" game concerning. Early E36 cars had all kinds of problems, but later versions are well sorted out. The E46 has auto-box problems (again with a five speed, and BMW is bringing 6 and 7 speeds out?) and all sorts of electrical glitches.
If you're shopping older cars, say a 1994/95 5-series vs. a 1994/95 E-Class, the Mercedes is far ahead of the BMW for low operating costs, overall reliability, and build quality. They are both the "last of the line" for their particular models, and the Mercedes is much better. The main problem is the resale value. The Mercedes is priced much higher than the BMW, thanks to the knowledge in the market.
The E39 is a pretty good car, but it's shockingly expensive to maintain. My neighbour has a 540i and it costs a fortune to keep up. They traded a W140 S320 in for it, and the Mercedes' overall costs were a fraction of the BMW's. However, they're wealthy and don't really care. Most of us are not so fortunate.
I would buy a 1998 E36 BMW 328i. Excellent car.
1998 C230 "Black Betty"