Wiper acting stupid
I can't really tell what the switch is mounted on, but some of those switches have to have a ground to it's case to run.
It might be getting it's ground through the motor and gear causing the intermittent issue and the clicking with headlights flickering.
Simple test to just use a wire that's connected to ground and touch the wiper switch case with the wipers on and see if it clears up.