The South was certainly fighting for independence towards maintaining slavery. Was ending slavery as large a motivator as maintaining the Union for those in the North?
To answer the question in the title, in short, there wasn't one. To answer the question in the description, overall no, but for some groups yes. Many soldiers fought to preserve the Union; some fought to end slavery; many immigrants fought to prove their belonging in America; many African-American men fought, undoubtedly with the goal of ending slavery more on their mind.
Over 2,000,000 men enlisted in the Union army; around a quarter were foreign-born, and around 1/10 were black. With so many people in the army, coming from such different background, everyone has a personal reason for fighting.
I will go over a few main reasons, though. For the average white American-born Union soldier, their reason for fighting was often either financial or, as you mentioned, to preserve the Union. Ending slavery rarely was viewed as the end goal of the Civil War. As a matter of fact, some Union soldiers were quite racist themselves. One quote that best demonstrates this, from a man named Thomas Donahue, after witnessing the massacre at the Battle of the Crater, “All that I am sorry for is that the Rebs did not capture every n***** there was there and Shoot them for I think that we have got white men enough in the North to fight our battles.” In fact, in that Battle Union soldiers joined in the massacre, as one writes, "we was not about to be taken prisoner amongst them n******.” Further, a group of Union doctors captured refused to operate on USCT prisoners until threatened by a local doctor in Virginia. Those are not the actions or words of men fighting to liberate slaves.
Another motivation for Union soldiers was financial. The bounties by the end of the war for enlisting were up to $1000, or around $30,000 in today's money; in the Confederacy, bounties only reached $100 Confederate dollars, a much, much smaller sum, as Confederate dollars were worth less than Union dollars. There was also a recession at the beginning of the war, making finances tight for many people in both the North and the South, If you're interested more in this particular motivation, I would recommend William Marvel's Lincoln's Mercenaries: Economic Motivation among Union Soldiers during the Civil War.
Many men also fought to preserve the Union as well; many men in their diaries record a keen sense of ideological duty towards preserving the Union. Something to remember is that by 1870, nearly 90% of white Americans were literate, so pamphlets and newspapers could be circulated widely. Lastly, the disclaimer for many of these is that those who strongly believed in the cause were more likely to die, and those who died were more likely to have their diaries or letters saved by parents, children or spouses.
Many black men who fought for the Union did so as a way of exacting revenge upon slave-owners, freeing family members who were still enslaved, or furthering African-American rights more broadly in the country. "Remember Ft. Pillow" was a rallying cry for USCT troops, after the infamous massacre there. Another key indicator of their devotion to the cause was their casualty rates: just over 20% of USCT troops died in the war, versus around 7% for white troops. Lastly, the ideology of furthering African-American rights is best summed up through this Frederick Douglass quote: "Once let the black man get upon his person the brass letter, U.S., let him get an eagle on his button, and a musket on his shoulder and bullets in his pocket, there is no power on earth that can deny that he has earned the right to citizenship." The valuable thing about this quote is that Douglass' argument relies on USCT troops doing something to benefit the Union, i.e., keeping it intact, not just doing something to benefit themselves. Were the main motivator of the war abolition, the link between an African-American man joining in the war and their citizenship after the war would not be so clear. One difficulty as a historian is that most black men were not literate, and so relatively few writings in their own voices remain.
The final main group I have not addressed is those born in foreign countries. My knowledge is most surrounding Irish soldiers, so I will focus on them, though I do not intend to diminish other foreign-born soldiers. At the time, racial tension between Irish-Americans and African-Americans was quite high, and as it became more and more clear that the war would result in abolition, they became more and more anti-abolition. As Frederick Douglass, who visited Ireland during the time fo famine, wrote, "The Irish who, at home, readily sympathize with the oppressed everywhere, are instantly taught when they step upon our soil to hate and despise the Negro. They are taught that he eats the bread that belongs to them." Before the war, many question the Irish's loyalty towards the Union; this was exacerbated by Colonel Michael Corcoran's refusal of an order to parade before the Prince of Wales, remembering the famine of fifteen years prior. Many questioned his loyalty, or claimed that he had a dual loyalty, and could not be trusted in time of battle. When the war came, many simply fought for national reputation, or in the hopes that they could one day cross the sea and liberate Ireland.
In short, every man in the Union army had his own reasons for enlisting, and they could be quite different, though I've outlined a few major ones here. If you're interested in the more personal stories, I would highly recommend James McPherson's book What They Fought For 1861-1865, it's really excellent. I hope this answered your question.
Sources:
https://nces.ed.gov/naal/lit_history.asp [for literacy rates]
The Battle of the Crater, by John F. Schmutz (2012)
The Immortal Irishman: The Irish Revolutionary Who Became an American Hero, by Timothy Egan (2017)
Lincoln's Mercenaries: Economic Motivation among Union Soldiers during the Civil War, by William Marvel (2018)
What They Fought For 1861-1865, by James McPherson (1995)