Headlights do not work on an '03 Subaru Forester high beams and fog lights do work and when I switch to high beams or fog lights the black and blue relays behind the glove box are clicking?

If some of the lights work on the car and some are just clicking, there may be a short in some of the electrical wiring. There may also be a problem with the electrical relays, fuses, or actual bulbs.