I have a 2003 Ford Sport Trac and the drivers side tail light went out a few months ago. The bulb was spent and I replaced it. After a couple of weeks it stopped working again, but the bulb is fine. Since then it has been working some days and not others. It worked when for a couple of weeks straight — including passing inspection — then started behaving erratically. I replaced the socket and it the problem persists. I'm guessing it has to be in the wiring. Where/how should I start checking?
The first thing to check is the contact points between the bulb and the bulb holder. Is it corroded? If it is then you will get the symptoms you described.
Next would be the checking cable and the connections. Is properly connected (No loose parts). It the cable sheet intact over the whole length or will it short now and them (measure with an ohm meter at the moment it does not work).
If the bulb, bulb socket checks out another common area to look is the switch itself--on the column. The contacts can get corroded over time (especially so on old cars where the current for the bulb flows through the switch).
As others have suggested examine the wiring paying particular attention to the grounds. On a vehicle this old corrosion starts to effect the quality of the chassis connections. They can be difficult to follow and a wiring diagram won't pinpoint where they terminate. If you can determine which wire is the ground you can run a test wire back to the battery negative terminal to see if the lights work better. Then find the grounding point and clean the frame with a wire brush or file and reattach the cable. Hopefully this will clear up the problem.