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.
Egads used to mean "ye gods" and now is more closely linked to "OMG" or "oh god"; Some people think there is only one god, so egad has evolved to express that idea. At the heart of it is the notion that god is a trickster who screws with us.
We use it to say that something severely messed up has just happened.
Egad--my computer crashed and I lost all my work. Again.