1769, "short pin passed through the eye of a rope," a nautical word of uncertain origin, perhaps a frequentative form of tog "tug." Meaning "a kind of wall fastener" is recorded from 1934. Toggle bolt is from 1794; toggle switch first attested 1938.
1836, from toggle (n.). Related: Toggled; toggling.
To change a bit from whatever state it is in to the other state; to change from 1 to 0 or from 0 to 1. This comes from "toggle switches", such as standard light switches, though the word "toggle" actually refers to the mechanism that keeps the switch in the position to which it is flipped rather than to the fact that the switch has two positions. There are four things you can do to a bit: set it (force it to be 1), clear (or zero) it, leave it alone, or toggle it.