I am certainly no expert on the longevity of BMW's. So a lot of my answer depends on how long you would keep the BMW if you did the buyout. Figuring on $2,000 for brakes and tires, which I believe is more than generous. You would then have $20,000 in the cost of the automobile.
So if you compare that to the lease option after 40 months (500 x 40) you will have spent that much again. If you are OK with having a bit older car that retains its looks well then if you were to keep it for longer than the 40 months then theoretically you would have broken even. Then you could take a “portion” of the lease payment and save it for repairs and still make out quite well. Most of the German engines are built for up to 200 – 300,000 miles.
Here is a link to http://www.cargurus.com/Cars/Discussion-d1512_ds538116 a post I think may be helpful
One other thing, is that while you aren't paying the lease payment you can bank what you don't need for repairs just like you are paying the monthly fee once you payback your initial buyout. Then when you need a car those 500/month payments will have accumulated and you will either be able to purchase a new car with cash or close to it. It works, if you are disciplined we have been doing that now since 1986. So we just keep paying a car payment to ourselves and purchase cars for cash and don't waste any money on interest.