Sounds like a weak ground. You need to find the wire that grounds the light (usually attached to a screw into the frame), take it loose, clean it and clean the area where it attaches. You could even rub it lightly with some sand paper to remove the oxidation on the metal. Then, reattach it snugly and see what happens.
Grease the ball hitch too. Sometimes you won't get a good ground if the ball is rusty or dry, and metal to metal, will grind on the ball to make it "less round".
My trailer hitch shop has found elderly light fixtures that needed replacing, so at times you just can't "fix it" without putting in a new fixture. The trailer light on mine shorted out the entire trailer light system, but lights worked when wet, like in the rain! We got new LED tail lights, which are MUCH more visible, so a good upgrade and no more light problems.