As I understand it, Maryland was very much up for grabs in terms of whether it was going to join the Union or the Confederacy. There was considerable sentiment for joining the Confederacy. In fact, a regiment of Union soldiers on its way through Baltimore was actually attacked by a mob, with four soldiers being killed.
In the end, the state stayed with the Union largely because of Lincoln's crackdown on Confederate sympathizers. He suspended the writ of habeas corpus and jailed many pro-Confederate leaders.
If Maryland had gone the other way, all Northern access to Washington, D.C. would have been cut. This was the main strategic value of the state Of course, the added population and economic power of the state would have helped the Confederacy. Finally, losing Maryland would surely have been a propaganda/morale loss for the Union.
Lincoln would never have allowed it. How could he? It was a border state that surrounded Washington DC on three sides, with rebel Virginia across the river on the 4th side. If Maryland left, the capital would be surrounded by a foreign country and effectively under siege.
Lincoln recognized the danger. When the Baltimore City Council undertook a resolution supporting secession, Lincoln had them all arrested, including the Mayor, and locked up for two years without charge or trial. He did the same with more than 2000 others in Maryland who were sympathetic to the southern cause, openly breaking the Constitution and reinforcing southern claims that he was a dictator. He had no choice, as if Maryland went, the war was likely lost for the Union.