You don't reference what year your X5 is, but the pre-2002 models had a design that just invited water to attack, thus the corrosion referenced by MSUSaul. There are 4 screws holding the license plate light bar in place, simply remove those 4 screws and inspect the wiring and the bar itself. The problem should be pretty self-evident.
Myself, I replaced my bar on my 2001 with one from a newer X5. It's a much better design and I now never have any issues with the license plate lights.