The south was very highly class based. There were very rich land owners, who were a very small minority. They were the ones who owned the slaves and wanted to leave the union. However, the soldiers were poor men who did not own slaves and did not stand to gain anything from the war. They simply gave everything in order to "defend their homes" from what they saw as northern aggression. But the northern aggression was really against the rich. So poor people who never owned slaves died to preserve the rights of the rich land owners.
Also, in the north, there was more of a middle class. There were more middle income farmers and craftsmen, and not so many super rich, also not many very poor. So they were mostly ordinary people fighting in the north.