Penn and Teller are Las Vegas' premiere magic act. They are in the genre of comedy-magicians who take their craft seriously, but try to entertain audiences by revealing some alleged secrets while at the same time going crazy illusions. They have crossed over into many television projects, like Fool Us, a television show which professional magicians attempt to stump Penn and Teller on their tricks.
The art of magic is the slight of hand, misdirection, and logical interruption of a person's perception to surprise them with an unexpected result - - - like finding one's card in shuffled deck to sawing a woman in a box in half. The latter uses a magic box to create the illusion of a saw blade tearing a woman in half, then separating the box into two halves.
If you want to know how that illusion is done, the internet probably has the answer.
If you want to know how the LOST island "magic box" works, then that is a different story.
We were told by Ben that the island is like a magic box, and if you want something badly enough, your wish will be fulfilled. In Locke's case, it was revenge upon his father, Cooper, who was suddenly transported to the island, held captive, then later killed in another revenge moment by Sawyer.
But what was the magic box?
It was never explained in the scripts. It may be a writer's slight of hand to move the action along without any rational basis for it. It was a tool to accomplish a plot twist without explaining it.
There are several ways to view the "magic"of the island through the metaphor of the box.
1. It could be a wish fulfillment center. If one believes in the island like children believe strongly in Santa Claus, you wishes will be granted by the island. Examples: Ben got cancer and needed to cure, so the island fulfilled his wish by crashing Flight 815 with Jack on board.
2. It is a dream catcher. The island EM fields can tap into human memories and recreate them in physical forms. This would explain Kate's horse, Walt's polar bear comic and Jack's father being present and seen on the island. Instead of theater of the mind, it is actual theater of the island as memories become props. (Perhaps, this is how the smoke monster was created, through the nightmares of children about things attacking them in the dark.) The stronger the emotional tie to the memory, the faster the island conjures up the prop.
3. It is a Pandora's Box. The island is the mythological repository for the jar of all evils that the god, Pandora, sent to Earth to create pain on mankind. For those who have evil in their heart, like Ben, they could access the evils inside the box. Locke was so hateful toward his father, that he wanted to kill him, so the box provided Cooper to Locke.
4. It is Room 23, a mind control experimental lab. Those who were held captive or part of Dharma could have been exposed to the techniques of mind control. As a side effect, or part of the program, vivid memories are implanted into subjects which seem real to them outside the laboratory. Hurley can talk to dead people because those conversations were implanted into his memories.