I am having similar problems with my '02 E39.
The wipe every 8 seconds is the failsafe mode for the intermittent wipers -- my car will do this even if I completely DISCONNECT the rain sensor. AFAIK, a bad relay would keep the wipers from working at all.
My rain sensor works for a short while, maybe a few minutes, before going into failsafe. You can tell if the rain sensor is still alive by adjusting the sensitivity on the wiper stalk with the wipers in the intermittent/auto position: Any time you click to a new sensitivity step, the wipers should wipe once. If they don't, and the sensitivity knob doesn't do anything, then the rain sensor is off-line. I have to turn the car off and back-on or unplug and replug the rain sensor for it to start working again, but then it only works for a few minutes.
If your rain sensor works at all (e.g. the sensitivity adjustment does something or it responds to rain, even if only initially), then the sensor may be good. Try making sure the glass is very clean and free of coatings. RainX supposedly causes problems, but I had RainX on my windshields for years without any issues with the rain sensor. My problem seems to be getting worse -- the sensor used to work for an entire trip about half the time, now it always goes dead within a few minutes.
In my case, I suspect a failing sensor or slow age/sun degradation of the plastic lens, adhesive, or other components that keeps the sensor from reliably detecting the difference between a clear windshield and rain. From there, the software probably forces it in to failsafe.
FWIW, the rain sensor is a complex little gizmo, with an array of 4 or 5 reflective photo gates and a microcontroller. It sits on the K-bus with the light control module, your IKR (hvac), windows, seats, and all that stuff. It has its own diagnostics and probably reports its own fault codes if you want to pay somebody to plug your car in and read them...
I might try picking one up on e-bay to see if that helps. Replacement is an easy 2-3 minute job. Google that or post back here if you need instructions.