Rachel R. answered 10/24/19
Expert Historian and Teacher
Lincoln's presence at Gettysburg is due to a number of factors, some that are in the context of the wider Union war effort, and some more immediate. The Battle of Gettysburg (July 1-3, 1863) was fought due to General Robert E. Lee's efforts to bring the war to the northern states through invasion, and take the economic and military pressure, as well as physical devastation, off such southern states as Virginia and North Carolina by diverting the Union Army to other fighting fields. Linked to this was a need for supplies by the Confederate Army; the state of war in the southern states was beginning to leave the Confederate Army with a lack of supplies, especially foodstuffs and basic equipment as state treasuries were beginning to feel the pinch in terms of finances.
The Union's victory at Gettysburg was a shocking blow to the Confederacy and to Lee personally, as (all indications point to his) he truly believed that the Confederacy would walk away with a victory. Both the Confederacy and the Union had things riding on a victory. 1.) Confederate victory would have shifted Union offensive tactics to defensive tactics on a more permanent basis, and shifted political negotiation power to the Confederate government's benefit (e.g. actual creation of the Confederation States of America becomes that much more realistic if the Confederacy has a presence in a northern state). There was also the morale issue at work for both armies, both for soldier and civilian. 2.) A Union victory was necessary: a.) to maintain the validity of Lincoln's presidency (many were questioning his leadership - civilian and military - at this point in the war and whether he was capable of providing a speedier end to the war); b.) convince Congress that the Union could actually win the war (remember: Victories at this point in the war were astronomically Southern); and c.) prove Union military strength. The Union victory brought major morale to that army and weight to Lincoln's presidency, allowing him to move forward with the plans laid out in the Emancipation Proclamation to free slaves in states in open rebellion.
So, more broadly speaking to the big picture, Lincoln's presence at Gettysburg in November 1863 was to speak to the Union's victory, but also to the shifting/changing course and purpose and aim of the war (saving the Union, democratic government preservation, freedom for all). His presence was also, and arguably more importantly, to try and bring the nation together and speak to the cumulative human experience of everyone living through the war, as he undoubtedly recognized not only to cost to the Union army and civilians, but to the Confederacy as well.
More immediately, Lincoln was at Gettysburg to open/commemorate a cemetery that honored the Union dead who'd fallen during the battle. Even in November, soldiers' bodies were still out in the open and being moved for burial to the newly-planned military cemetery. It should be noted that Confederate dead who'd been left behind were not buried there, but more typically were put in shallow unmarked graves elsewhere due to their "traitor" status. He recognized that this opportunity could be used not just for memorializing the memory of those fallen with a cemetery, but to begin bringing the country back together while also pushing a Union agenda.