At least 20%? Are you sure?i doubt there were 10,000 Federal infantry formed on the ridges. My concern was the artillery that the Confederates could not answer.
Assuming the CSA troops pushed the infantry, and the guns limbered up, Lee would have lost at least 20% of his army gaining a town with little value
Lee's army is usually estimated at 75,000 (which is effectives) and the historical day one casualties were ca. 6,000 for the Confederates - while 20% of 75,000 is 15,000.
That would amount to 9,000 casualties just gaining the ridge, which is comparable casualties to Pickett's Charge, and Pickett's Charge was an advance followed by a twenty-minute firefight in musket range against an enemy (1) protected by a stone wall and (2) supported by several batteries discharging cannister.
Even if artillery does a lot of the killing, you sort of need the infantry to keep the enemy infantry in optimal cannister range as otherwise they just advance right through it.
As for the town being of little value, the area of the town is the junction which Meade needs to unite his army in a reasonable time frame. (Specifically he needs to be able to unite forces marching along the Baltimore Pike and the Taneytown Road without having to either bridge Rock Creek or funnel everything south to the next crossing south of the Baltimore Pike bridge, with attendant loss of time.) There's a reason why armies have fought over crossroads and junction towns for centuries - it only really started to go away with the rise of air-mobile forces - and if Lee takes the ridge on day one then Meade has only two options.
1) Pour the rest of his army into the Gettysburg area along roads that are not mutually supporting, letting Lee essentially get the benefit of interior lines to crush only part of Meade's army.
2) Concentrate his army at the next set of junctions south, which in practice means the Pipe Creek Line. This is losing a battle on Union soil.