When it was first used in the late sixteenth century, the word loophole referred to those narrow slits in the walls of castles used to protect archers while shooting. Somehow this got associated with "means of escape", and in the 1660s that emerged as a new definition. As the word increased in usage (it peaked in 1985), it got associated with more and more figurative contexts, and here we are today. Going back, the loop in loophole is actually not related to the word for the curved shape that we know today! It comes from the Middle English word loupe, which meant "opening in a wall" in general and is thought to trace to a Germanic source meaning something like "peek" or "watch". Hole is just hole (which makes loophole a bit redundant): that, through Old English hol and Proto-Germanic hula, derives from Proto-Indo-European kel, meaning "cover".
Hello! I'm Adam Aleksic, a sophomore studying government and linguistics at Harvard University, where I co-founded the Harvard Undergraduate Linguistics Society. In addition to etymology, I also really enjoy politics, vexillology, geography, board games, conlanging, and law.