The Black Spider's motivations are detailed in the Campaign Module
Since the Lost Mines of Phandelver Adventure is made freely accessible by Wizards of the Coast, I'm going to quote it here, but I'm putting it in spoiler markup to avoid spoiling players who might be in an (unmodified) LMoP campaign.
Even though he intends to kill the characters, Nezznar is curious about them. Given the chance, he quizzes the characters at length regarding their identities, allegiances, interests, and goals. He files it all away in memory in the hope that someday he might find a use for what he learns.
Nezznar admits to being the Black Spider, and to using the Cragmaw goblins and the Redbrands to ensure that Wave Echo Cave remains his secret. He will say or do anything to put the characters off their guard, including promising to surrender or proposing cooperation against the monsters impeding his progress toward reaching the Forge of Spells. However, he betrays the characters as soon as they outlive their usefulness.
—Roleplaying [The Black Spider], The Lost Mines of Phandelver, Chapter 4
There's also some corroborating information found in the introduction of the module:
Unfortunately for the Rockseekers, they are not the only ones interested in Wave Echo Cave. A mysterious villain known as the Black Spider controls a network of bandit gangs and goblin tribes in the area, and his agents have followed the Rockseekers to their prize. Now the Black Spider wants Wave Echo Cave for himself, and he is taking steps to make sure no one else knows where it is.
—Background, The Lost Mines of Phandelver, Introduction
Below is my interpretation of what this says about their motivations, which might be obvious from context, but again, in spoiler markup:
Essentially, Nezznar wants the Forge of Spells all to himself. It's a powerful magical landmark that facilitates the construction of magical items; it has intrinsic value in multiple ways. His motivations really aren't all that different from the Rockseekers, except that the campaign module frames his claim to the forge as being less legitimate than the Rockseekers. Regardless, he attacks the players because he views them as being a threat to his claim. As stated in the module, he doesn't attack immediately, and might even assist the party if the cave is still full of monsters, but he absolutely intends to betray them in order to keep the secret of the cave.
Being essentially the "Final Boss" of LMoP, he orchestrated Gundren's capture, and is more-or-less responsible for all the events of the campaign that occurred in reaction to the Rockseekers' expedition, including funding the Redbrands and the Cragmaw Goblins. So if the Adventurers rescued Gundren, they have good reason to view the Black Spider as an enemy, rather than as a mere annoyance or obstacle.