Old English apa "ape, monkey," from Proto-Germanic *apan (cf. Old Saxon apo, Old Norse api, Dutch aap, German affe), perhaps borrowed in Proto-Germanic from Celtic (cf. Old Irish apa) or Slavic (cf. Old Bohemian op, Slovak opitza), perhaps ultimately from a non-Indo-European language.
Apes were noted in medieval times for mimicry of human action, hence, perhaps, the other figurative use of the word, to mean "a fool." To go ape (in emphatic form, go apeshit) "go crazy" is 1955, U.S. slang. To lead apes in hell (1570s) was the fancied fate of one who died an old maid.