This is an odd one. Words and lyrics are synonyms (I can't spot a difference between Who wrote the words? and Who wrote the lyrics?, andor Learn the words orand Learn the lyrics—except that lyrics founds fancier, as you'd expect from a Greek borrowing versus a native Germanic root). Nonetheless, they do not go with the same prepositions.
With words, I prefer to over for:
The words to this song are great
? The words for this song are great
But with lyrics, I prefer for over to:
? The lyrics to this song are great
The lyrics for this song are great
My guess is, there's nothing principled here, just an ad hoc quirk in how English has developed.
A couple of other observations. Both words and lyrics seem to go with of (and possibly in):
The words of this song are great
The lyrics of this song are great
The (dis)preference of to and for can be overridden by the verb:
Who put these lyrics/words to this song?
Who wrote these lyrics/words for this song?