What was it about Gettysburg that prompted Lincoln's words? The most commonly accepted answer is that the North had won the Battle of Gettysburg in July 1863. Up until that time, there hadn't been many Union victories, and certainly none that had taken place in the North (most of the Civil War was fought in the South). Lincoln would have wanted to use this victory to gather support for the war, which had become increasingly unpopular in the North as it dragged on.
It's true that Lincoln had received his invitation to speak only a few weeks before the cemetery dedication, but he had had four months to gather his thoughts after the battle. The process of identifying and burying the bodies took a long time, and since more than 50,000 soldiers were killed, injured or missing, there was a lot to consider before the cemetery could even be constructed.
As we mentioned, Lincoln's speech wasn't the feature presentation that day. That honor went to Edward Everett, who was considered a superstar orator. And while today we might assume that Everett's speech hasn't endured because it was so long, attention spans were a little better during Lincoln's time. People expected and wanted to hear lengthy speeches. Movies, television and radio hadn't been invented, so unless people were able to get to the theater for a stage production, a traveling orator might be the only professional entertainment they had access to. Everett's account of the battle was the modern equivalent of a "Dateline NBC" or "48 Hours" special. Orators like Everett could draw a huge crowd on name alone, so the pressure was mostly on him to deliver a gripping and educational performance.
Lincoln's speech, on the other hand, was almost an afterthought. He was the president, so it was still important, but he just wasn't the reason for the crowd.
Lincoln arrived at Gettysburg the day before the speech, which gives some indication that he knew his speech was still important. Considering a president's busy schedule, to make time for an extra travel day even in the 1860s was a little unusual. A crowd of 15,000 ended up seeing the speech, so Lincoln was correct in assuming that had he waited until the day of the dedication to arrive, he may have missed the ceremony. The crowd that gathered in the small town of Gettysburg overwhelmed all of the roads and inns. Other politicians who waited to arrive missed most of the ceremony.
While there are plenty of legends about how Lincoln came up with the speech, most modern scholars say that he had researched his subject and the battlefield -- and had written at least thoughts, if not a first draft, for his speech -- before he left Washington.
Today, at least five versions of the Gettysburg Address exist -- microphones and recording devices weren't around at the time, so word-for-word transcription was nearly impossible. There are a few newspaper accounts of the speech and Lincoln had a few copies, one that may have been his reading copy and some that he distributed to Everett and historians. Most of the discrepancies in the text are minor revisions Lincoln made after he had delivered the speech. The Library of Congress has preserved two copies, one of which is considered the earliest draft and the other a copy Lincoln gave to his private secretary, John Hay.