Once Lee realized Grant was after him and not Richmond, but also that he couldn’t abandon Richmond, how could Lee defeat Grant? Let’s speculate. What could Lee have done to defeat Grant?
Multiple different ways, from the onset of the campaign all the way to the James.
Put Longstreet's Corps at Jackson’s Shop or Orange Springs instead of around Gordonsville, enabling it to arrive on scene faster at the Wilderness and thus secure the Brock Road for the Confederates. At that point, Grant has his back to the river and Confederates everywhere else blocking his ability to maneuver. He can either slam head first into them-ala Cold Harbor-or he has to withdraw across the river in defeat.
Moving past the Wilderness, Gordon Rhea
notes of Lee's missed opportunity at the North Anna:
Lee's moment had come. His plan to split the Union army had worked, isolating Hancock east of the Confederate position, Burnside north of the river at Ox Ford, and Warren and Wright several miles to the west, near Jericho Mill. Hill, holding the Confederate formation's western leg, could fend off Warren and Wright while Anderson and Ewell, on the eastern leg, attacked Hancock with superior numbers. "[Lee] now had one of those opportunities that occur but rarely in war," a Union aide later conceded, "but which, in the grasp of a master, make or mar the fortunes of armies and decide the result of campaigns."
Lee, however, had become too ill to take exploit his opportunity. Wracked by dysentery, he lay confined to his tent. "We must strike them a blow," a staffer heard the general exclaim. "We must never let them pass us again. We must strike them a blow."
Have Lee avoid getting dysentery at the worst possible moment and there's a strong chance Lee can smash the Army of the Potomac good here. Lastly, we turn to the James and for that I cite Grant himself:
LEE’S position was now so near Richmond, and the intervening swamps of the Chickahominy so great an obstacle to the movement of troops in the face of an enemy, that I determined to make my next left flank move carry the Army of the Potomac south of the James River. Preparations for this were promptly commenced. The move was a hazardous one to make: the Chickahominy River, with its marshy and heavily timbered approaches, had to be crossed; all the bridges over it east of Lee were destroyed; the enemy had a shorter line and better roads to travel on to confront me in crossing; more than fifty miles intervened between me and Butler, by the roads I should have to travel, with both the James and the Chickahominy unbridged to cross; and last, the Army of the Potomac had to be got out of a position but a few hundred yards from the enemy at the widest place. Lee, if he did not choose to follow me, might, with his shorter distance to travel and his bridges over the Chickahominy and the James, move rapidly on Butler and crush him before the army with me could come to his relief. Then too he might spare troops enough to send against Hunter who was approaching Lynchburg, living upon the country he passed through, and without ammunition further than what he carried with him.
Interestingly, E.P. Alexander's own memoirs contain a speculation on Lee's opportunity here in line with Grant's thinking, but of a less dramatic opening. Alexander, like Grant, realized that the infrastructure and terrain was in Lee's favor, thus granting him the advantage of mobility. Instead of envisioning an offensive to bash Butler, however, Alexander speculated that the Army of Northern Virginia could've went on the defense to inflict a sort of "Super Cold Harbor" on Butler and Grant as he came into play. This isn't exactly idle thinking either, as during the thick of fighting Beauregard did manage to inflict 10,000 casualties upon the Federals to 4,000 of his own at a ratio of 2.5 to 1, a rate almost exactly that of Cold Harbor. This despite Beauregard being massively outnumbered to the extent there was often five feet per man in the trenches, while most of his command was either militia composed of young boys and old men or recovering wounded. This is understandable,
as morale among the Federals was absolutely shot to the point there was serious risk of collapse of capability in their forces. Lt. Col. Theodore Lyman, Meade’s Aide-de-Camp, noted the route of 30,000 Federals by just 8,000 Confederates on June 22nd as a clear example of the exhaustion afflicting the Army, while the day previously Meade himself, in a letter to his wife, stated that Army of the Potomac was in desperate need of rest lest its morale utterly collapse.