Your horn works by earthing a wire when you press the horn button (the airbag).
There could be several things wrong.
You could remove the airbag and check the earthing contact points are clean (probably little brass dots in the sprung frame).
The horn wire passes through a 'slip ring' which allows electrical contact whilst you can still turn the steering wheel.
Check to see if there's any electrical value (voltage) at the end of the horn wire with a multimeter - remember to have the ignition on. If not, I'd suspect the slip ring.
I think the earthing is through the steering column (so there shouldn't be a problem), but it could be earthing through a wire through the slip ring as well (so horn wire might be ok in slip ring, but earth wire isn't, so it's not earthing), I don't know without looking.
Slip ring is number3 in this diagram:
RealOEM.com BMW E39 M5 STEERING COLUMN SWITCH
If you get a new one, double check the part numbers as the realoem diagram is off my chassis number, yours might be different (but I doubt it).
HTH.