I would imagine if you keep driving on a bad battery it could cause damage to your alternator as it puts a lot of extra strain on the alternator. I would just recommend taking it to a battery place and letting them check if your alternator is indeed in bad shape (they should be able to do it quickly and free) especially if you buy the battery from them. As for the battery get the one made by East Penn Manufacturing as it is the same manufacturer as the OEM batteries and they fit in perfectly in the x5.
Changing the battery is a pain though as you have to pull it out from under the spare tire well but not too hard. Good luck.