Also, resigning one's commission and not fighting and resigning to take on a commission from another army that could and would fight against the army that you were in are two very different things.
People wouldn't object so much if Lee had left the army and sat out the war. Plenty of the Southerners who stayed in the US Army didn't see action in the War, but were given other assignments in the West or at West Point.
Lee didn’t exactly quit the US Army and take up a commission with the CS Army the next day.
He resigned from the US Army. He was then persuaded to take up leadership in what was the then-equivilant of Virginia’s National Guard. Which he saw as being defensive in nature.
He was only persuaded (and “persuaded” is the right word to use) to join the CS Army (first as a military advisor and then field commander) because he saw it is the only way to effectively defend Virginia.
Even his two invasions of the North were largely defensive in nature. A primary goal of the campaign that led to Gettysburg was to get the Union Army out of the Shennandoah Valley during the planting season and resupply the Army of Northern Virginia from Pennsylvania farms. While the Battle of Gettysburg was a major military defeat, when it came to those other goals it was actually quite successful.