You should check the headlight bulbs on your BMW E39 every six months. If you notice that a bulb is out, you'll need to replace it. You can buy replacement bulbs for the E39 at any auto parts store. The part number for the new bulb is on the base of the old bulb.
Open the bonnet and remove the electrical connector running to the back of the headlight ballast.
Turn the headlight bulb counterclockwise with your hand to unlock the bulb.
Pull the bulb out of the housing.
Insert the new bulb into the headlight housing, and align the tabs on the bulb with the notches on the housing.
Turn the bulb clockwise to lock it into the housing.
Reconnect the electrical connector to the back of the headlight bulb ballast.
Don't touch the glass on the new bulb with your fingers. Doing so can cause the glass to explode inside the housing when you turn on the headlights.