1: He almost had to gamble. He had already taken 15,000 causalities in the first two days and his army was exhausted. He was undoubtedly hoping the Union was in the same boat. The problem was that he no longer had the strength to continue operating in Union territory against a numerically superior foe that was only going to keep getting bigger. There were about 40,000 Union troops in and around Washington, so if he moves in that direction at this point, he could find himself between those men and the army of the Potomac, out numbered 2 to 1 or better with dwindling supplies.
Additionally, I think Lee realized that he needed a real win here in order to dishearten Northerners and try to negotiate a peace. A stalemate gains him absolutely nothing and costs valuable men and materials. If he pulls out at this point, where does he go that he could be effective? As a result, I think he realizes that he has to withdraw to Virginia or attack.
He has already hit both flanks and been repulsed. He knows the bulk of the Union's strength is on the flanks, so he almost has to hit the center if he's going to attack.
2. He underestimated the Union artillery and Confederate artillery was unable to effectively neutralize Union artillery. Meade actually anticipated the possibility that Lee might hit the center, especially since he had moved so many troops to the flanks. He positioned artillery across the battlefield accordingly so that they could fire on the center if needs be.
3. He overestimated the ability of his troops to maneuver under Union fire. In order to effectively hit the Union line and force a break through, Confederate forces needed to be able to maneuver across the battlefield in a somewhat coordinated manner. This is because breaking through is not enough. Lee needed the bulk of the army to come down in a fairly tight area in order to both push through and then put in reinforcements to hold and expand the breach. As Union fire broke up units and broke down the organization of the army, it became impossible for the plan to work even if enough men had made it to the wall to make the initial breakthrough because there would be insufficient forces to exploit the gap before the Union could respond.
4. Lastly, I think he overestimated his army's ability. They always managed to prevail and do the seemingly impossible, so I think he really probably believed that they could do so here as well. These were battle harden, experienced soldiers determined to win, and I think Lee really deluded himself into believing they could do so here as well.
I really think the charge was a combination of underestimating Union strength, artillery, and leadership, mixed with an exaggerated notion of what his army could accomplish and the realization that in order to win the larger war, he needed a major victory on Northern soil to break the North's will to fight.