As far as i readed about, i agree with
@CivilWarCollector post. Here below a couple of extracts from two free online pdfs you can find easily on the internet, which basically substain the thesis reported previously.
MD invasion
source : ‘battle of Antietam’ (staff ride guide) by Ted Ballard, 2006
In the days after second Bull Run, the government in Washington prepared for an expected confederate assault and Lee pondered his options. Insufficient numbers of troops, rations, ammunition, and other supplies prevented him from either attacking or engaging in a siege of the city. Washington was surrounded by extensive fortifications, bristling with artillery, and defended by large numbers of troops.
Lee could not afford to remain idle. It would be only a matter of time before Union forces reorganized and embarked on yet another advance into Virginia. To draw the Union army out of its entrenchments around Washington and into the open, Lee planned to march north of Washington into Maryland. A confederate movement north of the Potomac river would threaten both Washington and Baltimore and force the federal government to devote large numbers of troops to defend those cities.
In early september Lee wrote to confederate president Jefferson Davis that the army of northern Virginia was not properly equipped for such a campaign, especially since thousands of its men were barefoot. Nevertheless, Lee thought that his army was strong enough to keep the enemy occupied north of the Potomac until the approach of winter would make an enemy advance into Virginia difficult, if not impossible. Richmond would be safe, at least until the following spring.
A move which moreover would rally Maryland to confederate banner and gain european recognition.
PA invasion
source : ‘Gettysburg : a study in command’ by Leonard J. Fullenkamp
An invasion of Pennsylvania would:
-- permit subsistence of Lee’s army in the north
-- demonstrate to Northerners that their armies could not protect them
-- seize the operational initiative and preclude federal operations in northern Virginia for the summer. Moreover,
-- a successful operation in Pennsylvania may encourage foreign recognition
-- and would achieve decisive results, unlike western theater strategic options