Soldiers were paroled and allowed to return home. Those who swore the oath of allegiance to the US, and who applied for a pardon, were indeed pardoned for the most part. The most prominent exception was RE Lee. His application was mysteriously “lost” in the offices of the Secretary of Defence until it turned up in 1955 whereupon he was pardoned posthumously.
The only officer prosecuted was the former commander of the Andersonville POW camp. He was executed. The great remainder returned to civilian life in various capacities. Lee took up the Presidency of Washington University. James Longstreet, Lee's “old war horse”, actually joined the Republican party and had a prosperous career in a number of Federal patronage positions.
Among the political leaders, Jefferson Davis was jailed for several years under pretty trying circumstances until popular pressure North and South forced his release on parole. He returned to Mississippi and took up farming and writing his memoirs. Other former Cabinet members emigrated, some to South America, others to Cuba and the West Indies, still others to Canada and Mexico. To my knowledge, none were prosecuted and most emigrés eventually returned to the US.
As for the general soldiery, they returned to their homes and started over. An unknown number emigrated West with the great post-war expansion, others joined the US Army (ex-confederate general Joe Wheeler commanded the US cavalry division in Cuba during the Spanish-American War). But most ordinary veterans, lacking the resources of the officer cadre, remained in the South and just struggled to survive through the turbulent Reconstruction period.