Depends completely on who you would be asking at that time. For the typical white Union soldier, the initial reason was one of adventure. These were kids of 18 and 19 who had never been more than 15 miles from home, and this seemed like a grand adventure at first. Later, northern troops fought on out of a sense of duty and to finish what they had started.
Black Union troops though fought for abolition, plain and simple. Sometimes for revenge for offenses past and present, or to liberate loved ones still enslaved. They were among the most motivated troops of the war.
Confederate soldiers fought mainly to defend their states and their country. As one white rebel put it in Ken Burns' Civil War series, "I'm fightin' cause you're down here".
AS stated before there were many individual reasons. there is no one blanket answer. I had an ancestor who fought for the Confederates because the Union burned his house and stole his pigs.