Sort of. There are secretly two parts to the question, each of which have a different answer.
Was Frodo incapable of destroying the Ring?
Emphatic yes. Tolkien says as much several times in his letters, but I'm going to quote Letter 191 (emphasis his):
If you re-read all the passages dealing with Frodo and the Ring, I think you will see that not only was it quite impossible for him to surrender the Ring, in act or will, especially at its point of maximum power
No, Frodo 'failed'. It is possible that once the ring was destroyed he had little recollection of the last scene. But one must face the fact: the power of Evil in the world is not finally resistible by incarnate creatures, however 'good'
The Letters of J.R.R. Tolkien 191: To Miss J. Bum (draft). July 1956
Was Gollum the key to destroying the Ring?
Not really. Gollum just happened to be in the right place, at the right time, at the end of the right string of circumstances. The actual key to destroying the Ring was Ilúvatar, the God of Tolkien's mythology.
The end of the story is a statement of Tolkien's moral philosophy, that salvation and the ultimate destruction of Evil is something that only God can accomplish.
Was Frodo just lucky that Gollum was there?
Again, no. Frodo himself caused Gollum to be there, by not killing him earlier in the story; as Tolkien writes in Letter 246:
Frodo had done what he could and spent himself completely (as an instrument of Providence) and had produced a situation in which the object of his quest could be achieved. His humility (with which he began) and his sufferings were justly rewarded by the highest honour; and his exercise of patience and mercy towards Gollum gained him Mercy: his failure was redressed.
The Letters of J.R.R. Tolkien 246: To Mrs. Eileen Elgar (draft). September 1963
Far from being the result of luck, Gollum's presence (and thus his being the instrument of Providence that achieved the Quest), was a direct result of Frodo's earlier mercy, and his (accidental) destruction of the Ring was part of Frodo's reward.