Because 17 years earlier, Gandalf had no more than a pretty firm suspicion that Frodo's ring might possibly be the One Ring—even though Saruman had denied this was possible. He told Frodo:
"[The Ring] may have other powers than just making you vanish when you wish to."
"I don't understand," said Frodo.
"Neither do I," answered the wizard. "I have merely begun to wonder about the ring, especially since last night."
(The Fellowship of the Ring, Book I, Chapter 1, "A Long-Expected Party")
Gandalf had been alarmed by Bilbo's reaction to the suggestion of giving up the ring, and by his description of feeling "thin and stretched"; and most of all by Bilbo's use of the term "precious" to describe it. He felt that it was important to do research into the ring—research which he summarizes for Frodo in Chapter 2 of Book I, and for the Council of Elrond in Chapter 2 of Book II.
@Alfe asked why Gandalf took 17 years to find the answer to whether this was the One Ring or not, especially given the possible danger to Frodo and the Shire generally.
It appears that Gandalf had at some point after Bilbo's return in 2941 been suspicious enough to request that the Dunedain set a guard on the Shire—we're not told when, as far as I can discover, but Gandalf does tell Frodo in "The Shadow of the Past",
Even when I was far away there has never been a day when the Shire has not been guarded by watchful eyes.
(The Fellowship of the Ring, Book I, Chapter 2, "The Shadow of the Past")
After Bilbo's departure in 3001, Gandalf felt sufficiently alarmed that he consulted with Aragorn and had the guard doubled. Furthermore, he and Aragorn seem to have decided that the best way to decide whether Frodo's ring was The Ring was to try and connect the dots from Isildur to Gollum by finding where Gollum got his ring, and when. This of course would require finding Gollum:
'And I,' said Aragorn, 'counselled that we should hunt for Gollum, too late though it may seem. And since it seemed fit that Isildur's heir should labour to repair Isildur's fault, I went with Gandalf on the long and hopeless search.'
Then Gandalf told how they had explored the whole length of Wilderland, down even to the Mountains of Shadow and the fences of Mordor. There we had rumour of him, and we guess that he dwelt there long in the dark hills; but we never found him, and at last I despaired.
(The Fellowship of the Ring, Book II, Chapter 2, "The Council of Elrond")
No wonder he despaired. Wilderland is not specifically defined anywhere, it's not a country; but it appears from the maps in The Hobbit and The Lord of the Rings that Wilderland is the strip of land east from the Misty Mountains as far as the Lonely Mountain in the north, and south apparently as far as Rohan; and then southeast from there to the borders of Mordor. That's a strip of land maybe five hundred miles long north to south and a hundred or a hundred and fifty west to east; a piece of land the size of the U.S. state of New York or bigger, being searched by two people, looking for an individual—known to be good at hiding—who had last been seen about fifty years previously. No wonder it took them seventeen years; the wonder is that they didn't give up earlier!
Gandalf gave up before Aragorn, and figured out another way to identify the Ring (by the inscription on the Ring) in early 3018. Just as he was setting out for the Shire, he heard that Aragorn had caught Gollum, and went to interrogate him. It was only after that that Gandalf felt completely free of doubt. Even then, after he came up to talk to Frodo, he wanted to verify his ideas based on the inscription clue he had discovered:
I still do not know, one might say. There is a last test to make. But I no longer doubt my guess.
(This, and all further quotes, from The Fellowship of the Ring, Book I, Chapter 2, "The Shadow of the Past")
And when Frodo asks, "Why did you let me keep it? Why didn't you make me throw it away, or, or destroy it?" Gandalf replies,
you must remember that nine years ago [i.e. in 3008, seven years after the Party], when I last saw you, I still knew little for certain.
So that explains why Gandalf waited until 3018; he just didn't feel certain enough. As far as why he allowed Frodo to wait until the fall of that year, it appears that first of all he wasn't sure that there was an immediate, pressing danger—he didn't realize how closely the Nazgûl were pursuing the Ring; and secondly, he didn't want to push Frodo too much. He did wish that Frodo took the threat more seriously:
"You ought to go quietly, and you ought to go soon," said Gandalf. Two or three weeks had passed, and still Frodo made no sign of getting ready to go.
But he was willing to make a compromise about the departure time:
He looked at Frodo and smiled. "Very well," he said. "I think that will do—but it must not be any later. I am getting very anxious."
By the end of June, he discovers from Radagast (sent by Saruman) that the Nazgûl have crossed the Anduin and are searching for the Ring. He wants Frodo to go immediately at that point. But Radagast also conveys Saruman's request for Gandalf to consult with him, and of course as soon as Gandalf goes, he gets captured. Gandalf does have a plan in place before leaving for Isengard; he writes a letter informing Frodo of the danger, and push him out of the Shire sooner, but he leaves his letter to Frodo in the hands of Barliman Butterbur, who loses track of it; and thus Frodo's departure doesn't in the end take place for another three months.