The Magic Lamp is an artifact with the ability to imprison and enslave genies. A genie enslaved by the lamp must do whatever its master commands. At some point before Shantae was born, its power was divided into three Magic Seals, rendering it powerless. These three seals came into the posession of artifact collectors known as the Barons of Sequin Land.
The lamp itself was recovered by Mimic from an unspecified ruin and later stolen by Risky Boots, who planned to use the lamp on Shantae and gain command of her powers. Since Shantae was only a Half-genie, Risky knew she couldn't actually control her enemy, so she settled for sucking the magic out of Shantae and commanding them to destroy their former master as Nega-Shantae. Though Nega-Shantae was defeated by Shantae, Risky kept the lamp.
Later, The Pirate Master's curse began to transform Risky's once loyal Tinkerbats into mutant Cacklebats. Shantae is given the lamp so that she can capture the dark magic coming out of the defeated Cacklebats, as well as suck up loose gems and fragrant aromas. During the final battle, the Pirate Master demands that Shantae give him all the dark magic in the lamp in exchange for Risky's life. Instead of dark magic, what comes out of the lamp is light magic, which Shantae absorbs to regain her powers and defeat the evil tyrant. At the end of the credits, the lamp is seen sitting at the bottom of the ocean, likely thrown there so that its power can (hopefully) never again be abused.