To draw the Union Army of the Potomac into a battle on favorable terms: Lee had been frustrated by his inability to defeat the Union army in a decisive battle on Virginia soil. He believed that by moving into Pennsylvania, he could lure the Union army into a battle in open terrain, where he could use his cavalry and artillery to his advantage.
To capture Union supplies and resources: Lee's army was severely depleted in terms of supplies and resources, and he hoped to replenish them by raiding Union depots and towns in Pennsylvania.
To threaten Washington D.C.: By moving his army close to the nation's capital, Lee hoped to create a sense of panic and uncertainty in the Union government and public. He believed that this could lead to a weakening of Union resolve and a willingness to negotiate a peace treaty.
To boost the morale of the Confederate Army: Lee's army had suffered a series of defeats in the spring of 1863, and he believed that a successful raid into Pennsylvania could boost the morale of his troops and reinvigorate the Confederate cause.
To divert Union attention from other Confederate operations: Lee hoped that by raiding Pennsylvania, he could distract the Union army from other potential threats, such as a Confederate invasion of Maryland or an attack on the Union-held city of Baltimore.