Get some deOxit on that lamp connector. Leave for a few hours then blast it with contact cleaner and an old toothbrush. See if it gets rid of that corrosion.
For the loom connector, even though the wire is a bit frayed it looks like it’s still connected ok. Get some heatshrink around the wire and connector to strengthen that frayed bit and re-test in the headlamp after you deal with the corrosion.
That corrosion damage looks like its been caused by water kicking up at the back of the headlamp unit and not moisture from inside, unless it was completely flooded inside?
Are all the plastic bits in place around your wheel arch liner and under the front bumper etc?