From the Super Mario Wiki, the Mario encyclopedia
The magic pendant is a pendant created by Kooky von Koopa that could bestow the ability to use power-ups to anyone, though only in the real world. Although Kooky was disappointed that the pendant did not work in the Mushroom Kingdom, Bowser actually expressed gladness, as it would be the reverse of the Mario Brothers powering up, since Luigi and Mario could not power up in the Real World.
In The Adventures of Super Mario Bros. 3 episode "Super Koopa", King Bowser Koopa uses the magic pendant to cause havoc for Mario and Luigi, becoming Fire Koopa, Raccoon Koopa and Frog Koopa, along with being able to ride in a Karoobi.
Eventually, the magic pendant became too strained after being used several times consecutively by Bowser, and overloaded before exploding spectacularly.
How the magic pendant works is relatively unknown, and why it only works in the real world is a mystery as well. Along with giving someone the ability to use power-ups, the magic pendant could seemingly create them. By zapping an object with the magic pendant, a power-up would appear in it, similar to how power-ups are found inside Super Blocks; the exception to this appears to be the Karoobis, as Bowser simply needed to zap a rather worn looking boot to transform it into a Karoobi. Also, it seems that after the user has already used a power-up, they simply need to zap themselves to use that power-up again, instead of creating another power-up from scratch. The magic pendant could also allow someone to use multiple power-ups at once, such as when Bowser became Fire Koopa and Raccoon Koopa at the same time.