Wrenches in the form of sockets-that is, a female driver to envelop the male head of a fastener-have existed for centuries.
Square heads and sockets were the easiest to make in the era when hand filing was the typical method of manufacture.