In 1611, Covarrubias defined the term "gafas" as following (text adapted):
GAFAS, instrumento con que se arma la ballesta [...] porque hace curvar y torcer la verga de la ballesta hasta encajarla en la nuez.
If you search in the CORDE this word before 1700, this is the meaning you are going to find for every match. Covarrubias said that "gafas" came from a Hebrew verb, "Cafaf", meaning "to bend". In the same dictionary, "gafo" was:
[...] un enfermo de cierto género de lepra [...] el cual [...] encoge los nervios de manos y pies: y particularmente les llamamos gafos a los tales enfermos por encorvárseles los dedos de las manos, como a las aves de rapiña.
In fact, by then it already existed the word
GAFAR, [...] arrebatar con las uñas, o con instrumento encorvado y gafo.
So, "gafo/a" just meant "torcido", "doblado" ("bent"). In the same dictionary we can find the word
ANTOJOS, los espejuelos que se ponen delante de la vista para alargarla a los que la tienen corta, invención admirable, y de gran provecho para los viejos y los cortos de vista, y para no cansarla leyendo o escribiendo.
These "espejuelos" or spectacles ("antojos" because they were positioned "ante los ojos") did not have a frame as they have today. But then someone invented a frame that made them fixed in your face via an elongation that went behind your ears. This elongation was curved, and thus it was something "gafo". In the RAE dictionary from 1803 we can see the following definition:
GAFAS. Las presillas, o manecillas, con que se afianzan los anteojos en las sienes, o en las orejas.
But in fact, from the first RAE dictionary from 1734 we can see that
GAFAS. En el estilo familiar, vale lo mismo que Antojos.
So at first, what was "gafas" was the mount with the curved elongations, and it was a colloquial word, being "antojos" much more formal until the XIX century, in which the term "gafas" began to be widely used in literature.