In order to understand how there managed to be a clash of two huge armies so deep in Union territory, we must attempt to place this event in the context of the ongoing Civil War.
In the spring of 1863, the war had been raging for two years. Battles were being fought and men dying in multiple places but generally on Rebel territory. The first major clash had come at Manassas / Bull Run and most of the early action took place in Virginia. The Union forces later initiated action in various other parts of the Confederate States but many major battles were still being fought in Virginia.
As Lee’s Army of Northern Virginia and the Union Army of the Potomac – under a series of leaders – repeatedly clashed they moved back and forth in a see-saw series of maneuvers that had depleted the land time and time again. Armies of this era, depended on the locals and the land to provide many of their supplies like food and animal feed. This plus the destruction of the actual battles had depleted northern Virginia to the point of devastation.
Lee found himself pushed farther and farther west away from the Confederate capitol at Richmond that his army had been founded to defend. Coming out of the winter lull, he had won and lost some battles but never the less had lost terrain so that he was farther west than he would wish to be.
And so we reach the point where Robert E Lee decides to change the flow of the war and invade the North!
[also see Section 22e ]