The New York Times has gathered an impressive group of historians to address this question. Panelists include Eric Foner, Stephanie McCurry, Patricia Limerick, and Nell Irvin Painter.
Here is a taste of McCurry’s piece: “The United States Won, Period“:
The question implies the possibility of a counterfactual answer: The South really won the war. I have heard this argument made, and I am not persuaded. I know the logic: The racism that emerged in the postwar U.S., especially but not only in the South, looked like slavery under a different name; the South won the war of history and memory, securing the honor of the cause and forcing reunion on Southern white supremacist terms. And indeed at a certain, meta-historical level, that is hard to dispute, especially the latter point. We still do battle to displace and discountenance ancestral Confederate histories.