It is a pagan way of saying omg. It comes from the saying "ye gods", and, as everyone knows, the greek and roman gods had a way of messing with people's lives. So when you say egads, in a sense, you're saying "you fuckers," but softly.
It is used to express mild dismay or frustration.