Interestingly, I feel that there is another layer to this, and that is Frodoโs mercy (mirroringย โthe pity of Bilboโ which Gandalf said would prove significant) at play, tangled up in his use of the Ring and the chain of events that would play out.
Frodo is sparing Gollumโs lifeย here, and shaping that into his curse. He is only cursing Gollumโcanย only curse Gollumโas an effect of this mercy; if Gollum were dead, he could not be cursed by Frodo or the Ring; his survival makes the curse possible and serves as payment for the curse: they are in effect making a bargain here, wherein Golllumโs life and his sentence of dying in the Fires of Doom should he take the Ring again are as one, a package deal, which Gollumย โacceptsโ by retreating with his life.
Then, once Frodo comes to Mount Doom, he cannot cast the ring into the fires; the Ring has him in thrall, since he has used it. Now into the picture again comes Gollum, whose greed for the Ring has surpassed his love of his own lifeโeven having been cursed with death should he touch it again, he craves it and demands it for himself, taking it from Frodo by force.
Thusย we see the Ringโs power divided against itselfโit has defeated both Frodo and Gollum, and its defeat of Gollum inspires Gollum to fight Frodo for it, invoking the curse. And thus Sauron, who hasย it, now, by virtue of both its erstwhile Bearers falling under its (and therefore its Lordโs) sway, is cheated out of it by the effects of Frodoโs act of mercy.
Frodo spared Gollum, and used the Ringโs power to set a curse, and when Frodo faltered, it was Gollum whom he spared who took the Ring from him and invoked that curse, falling into the Fires of Doom and, due to the same greed that defeated Frodo, taking the Ring with him.
If there had been no sparing Gollum, there would have been no curse, and Frodo would have had the task Isildur failed atโdestroying the (beautiful, useful, lovelyย ring)โset before him alone, and he may have succeeded, or he may have failed, or he may have tarried too long in the struggle for Sauronโs destruction to come in a timely fashion, or the resolution and the Ringโs destruction may have hurt him far beyond the loss of a finger.
Instead, there was Gollum, in thrall to Sauron yet doomed by Frodo, to take from Frodo both the Ring and the burden of destroying it. Frodo, in his mercy-tinged use of the Ring, effectively shifted the impetus behind the Ringโs destruction from himself to the doom laid on Gollumโand Sauronโs hold over Gollum made it a near certainty that the doom would come to pass: Gollum would die, and not surrender the Ring, and thus the Ring would fall with him into the fires of Mount Doom.
And Frodo โฆ like Indiana Jones in the Chapel of the Holy Grail, could avoid falling himself by either a willingness to let go, or the presence of a loved one to hold him back. Or, yโknow, Gollum deciding to bite rather than just grab. A few more options here.