My 1986 BMW 635 CSi has an automatic transmission and it recently failed to crank (turn over when I tried to energize the starter). Then, it would crank (and start) when I messed with the gearshift lever, and then it would fail to crank (and start) again.
The relevant parts of this car seem identical to a 1987 BMW 535i that I owned until recently, so what’s true for the 6-series is probably helpful to 5-series owners too.
The culprit was a loose connection. Wiring from the car runs to the gearshift selection unit via a plug, and if that plug is too loose, the car won’t start. It is difficult to push the plug in all the way, but it helps if you remove the ashtray and vertically pull the console up as high as it’ll go. Even a tiny bit of vertical movement can make the difference you need.
As part of troubleshooting the issue, I undid the plug completely and fed it out of the ashtray hole. The wires are long enough that I could plug it into a spare gearshift selector that I had handy. When I put that unit into Park or Neutral, the car started and otherwise it didn’t. This told me that the car’s wiring wasn’t the problem, and that the problem was the gearshift lever mechanism in the car, or the connection thereto.
The way the wiring works is interesting. A starter relay makes or breaks a connection in the main starting circuit. The gearshift lever basically intercepts the relay’s path to ground. The electrical plug to the gearshift lever has nine holes. The brown-and-black wire goes into the top center hole, the one with the bubble-shaped side as opposed to the smooth sides.
If you need parts for any of this, I sell them, but perhaps all you need to do is make sure the plug is tight. Normally, it’s a very tight fit so it’s unusual for it to be loose.