Note: This is based off a reply to a similar question that I answered here.
The Confederates had attacked on the Union flanks on the first two days of the battle, and since Stuart and his cavalry had arrived, it looked like another attempt to flank the Union line was going to come on day 3. Meade had reinforced his flanks and thus the centre looked relatively weak.
The intention was to silence the Union artillery in the centre and place a Napoleonic grand battery style barrage on the Union centre to hinder movement of reinforcements and disrupt the Union formations. Pickett's division, supported by Pettigrew's and Anderson's would charge straight ahead, not stop to fire and charge the Union position with bayonets.
At the same time Stuart and his cavalry was to flank the Union line and disrupt it, inserting itself between the Union lines of retreat and the Union forces.
If successful the attack would have broken the Union centre and more or less surrounded the Union right (northern) flank, hopefully causing an army-wide rout and a huge victory for the Confederates, with Stuart's cavalry in an excellent position to force fleeing Union forces to surrender, capture artillery and supply trying to retreat and so on.
Napoleon had done something very similar at the Battle of Austerlitz 1805 - feigning an attack on the flank of the Austro-Russian Army and breaking through its centre. It was one of the most decisive victories of the Napoleonic war and probably the finest victory of the Napoleonic forces. Lee had probably studied it at West Point (the Napoleonic Campaigns were essential parts of the curriculum at West Point Before the American civil war).
Several things went wrong with the charge. Firstly, the Confederate artillery proved unable to best its Union counterpart, and had to move its ammunition supplies back to now risk having them hit as the Union artillery engaged in counter-battery fire. This reduced the rate of fire of the Confederate artillery and locked them in an artillery duel with the Union artillery instead of dominating the terrain around the Union positions. Thus, when Pickett's men marched, the Union artillery was still very much a factor in the centre.
Secondly, Stuart's cavalry got embroiled fighting the Union cavalry and was never able to get in behind the Union line - this meant that Meade did not have to move reinforcements to the flank and did not have to worry about a large-scale flanking movement.
Thirdly, and in my opinion the largest factor, at the same time, as you can see on the map, Pickett's division realised they had advanced along the wrong axis and decided to wheel and march towards their original target - which was probably a cruicial mistake. Such a manouvre takes time when done with large amounts of men in formation, and the Confederate forces were under artillery fire from the Union artillery the whole time.
Once Pickett's division did reach its original assigned point of breakthough, the vast majority of men refused to charge home with bayonets despite specific orders to do so, and instead stopped and started exchanging rifle fire with the defenders, perfectly positioned in the killing zone of the defenders' rifle and canister (case) shot fire.
Only a few hundred men charged home - those that did carried the position but were thrown back by a Union counterattack since their flanks were exposed by the other men not advancing.
Overall, the original plan was sound, but the Confederate army lacked the resources to carry it out properly. The artillery was unable to do what it was supposed to do, the cavalry got stuck fighting the Union cavalry and the infantry of Pickett's division arrived with enough casualties to deter them from charging home as per their original order. Thus the attack failed.