I've been doing a lot of thinking about the events in the manga and this is what it's led me to. It is rather dark, so please read this with an open mind and at your own discretion.
Luffy: So, this factory is more than just a factory.
Sanji: It makes more than just Devil Fruits, though I'm not sure what this part is for.
Rebecca: It feels like we're in a morgue. Only none like I've ever seen.
Zoro: There's a section for stuffed dolls, wooden marionettes, metal ones with keys...
The group is looking at racks upon racks of children's toys. However, these toys are not like the ones they've seen walking around the island. They are lifeless, with nothing but sheer metal, cloth, or wood where their eyes should be, as if they were never there to begin with.
Robin: It certainly would explain the sign above the door.
Law: Death's Toy Box...
All of a sudden the racks begin to move forward, on a hanging conveyor belt. The lifeless toys go into another room.
Kin'emon: Let's follow them!
Usopp (shaking): Do we have to?
The group runs forward, following the racks. They enter the next room and stare in even greater disbelief
Outside the factory...
Yamakaji: Shouldn't we go in and apprehend them? It's a rare occasion to have so many targets in one place.
Maynard: We might have a full-scale battle on our hands if we intercept them out here.
Fujitora: No, we're staying out here, and that's final.
Yamakaji: But why, sir?
Fujitora: The things in that place make the blind rejoice, praising their imperfection the way a holy man praises God.
Back inside the factory...
Robin: What is that?
Rebecca: Where to start...It's the power source for this whole place. This machine is a marvel of science. It's purpose is to process what you see zooming around that glass ball you see on top.
At this point, the machine starts lighting up and its parts begin to whir. Toys go in and come out another door, alive, touching their heads and groaning like they're waking up from a bad hangover.
Sanji: No way.
Robin: Those things in that glass ball, don't tell me they're...
Rebecca: Yes. They're human souls.
Everyone takes a step back, mouths agape.
Luffy: That, that's insane!
Franky: How is that even possible?
Rebecca: With some help, Doflamingo has taken theory and made it fact. He has made use of a science called....
Robin: Applied Noetics. The theory states that thought and ideas have mass, and if believed by enough people, can take physical presence in this world.
Sanji: You said that Doflamingo's current nickname is "Heavenly Yaksha"? That's starting to make a lot more sense.
Rebecca: Instead of letting the souls of the dearly departed go to Heaven, they go to this machine and are reborn as a toy. After each rebirth the souls get weaker, until eventually they just stop existing.
Luffy (obviously angry): So, that bastard is interfering with death? That's unforgivable! No one decides life and death, especially not some stupid lunatic!
Zoro: So how do we destroy this abomination?
Rebecca (facing away, head down): Those six buttons arranged in a hexagon just below the ball. Top right, bottom right, left middle, top left, right middle, bottom left. (starting to cry) It'll cause a permanent shutdown.
Zoro reaches up to start the sequence. He presses the first button and is about to press the second.
???: You shouldn't go through with something so brash until you know exactly what it does.
The group turns and sees Donquixote Doflamingo standing in the doorway accompanied by Diamante, Baby 5, and Lao G.
Doflamingo: Rebecca, how about you tell your friends what else turning off that machine will do?
At one of Acacia's docks.
Zambia: Yo, captain Barto, we are stocked, locked, and ready to go!
Bartolomeo: Great. Everyone can take the rest of the day off. If you need me, I'll be in the crow's nest. You're welcome to join me if you want to witness something I've always wanted to see that most people never get to.
Zambia: And what is that, captain?
Bartolomeo: The exposition and demise....of a false paradise.
Back in the factory.
Rebecca: I...don't know what you're talking about...
Doflamingo: Yeah yeah. Drop the cute and innocent act. I know you want to deprive me of the pleasure of saying it myself. I can promise you I will not put it as lightly as you would.
Rebecca: If you destroy it, it will also... it will also release the souls of all the toys on the island.
Luffy: So you mean to tell me that....
Doflamingo: Half of the people on the island will die! If my contract with Kaido goes south, it's taking thousands of innocent people with them!
Sanji: You insane demented fuck! How could you do something like this! How could you be so selfish and heartless!
Doflamingo: You shouldn't declare something so bold until you have ascertained its certainty. You call me selfish, but what am I doing that makes me so? I gain absolutely nothing from putting these souls into toys. It makes people happy. I am letting people forever reunite with their loved ones! (he points to a small robot) The soul of a small child who drowned at sea is going in that one. Those parents will be elated to have their child back. As long as no one gets any crazy notions of heroism and grandeur into their heads, there's no threat or consequence.
Kin'emon: To even think about this idea, let alone implement it. What kind of crazy...
Doflamingo: This coming from the assholes who want to destroy my factory because some schmuck in a hat told you it was a good idea? I've created a paradise that transcends death and only punishes those who do wrong. I'm not the one doing anything wrong here, am I? Helping a yonko is just one of my many business ventures. If someone who matters has a problem with it I can stop it as easily as I start it. There is nothing I can't do. Ask yourselves, what are you doing here? Do you think this is my only factory? You wreck this one, I have five more to fall back on. You need to figure out why you're really here and I'm about to make it easy for you. Ask him (points to Law).
Law (seething with anger): You bastard. You know, it was twenty years ago today, that you sent my life spiraling down the path it's on now.
Flashback: North Blue, the island of Cocharasca.
Doflamingo: That's what you get for crossing the Donquixote Pirates! Loot the place boys, leave no stone unturned and no building unburned!
Buffalo (dragging someone over to Doflamingo): Hey, boss! I found one we missed!
The other pirates gather around as Buffalo tosses a six year old Law at the feet of his captain.
Doflamingo: How adorable, say kid, what's your name?
Law (scrambling to his feet, clutching an unsheathed scalpel like a sword): I...I am Trafalgar Law! I'll use this, I'm warning you!
Doflamingo: Hey, hey, don't flip out, we're just talking here. No need for violence.
Law: You killed everyone on this island, everyone I've ever known!
Doflamingo: Well, that's what happens when you don't follow the rules.
Law: You jerk!
He lunges at Doflamingo with his scalpel, but one of his crew reaches his hand out to grab him. Law brings the scalpel down and cuts off the man's hand at the wrist. There is no blood as the man's hand falls to the ground. Law is stunned at what he's just done, the man moreso that he doesn't feel any pain.
Doflamingo (grinning with interest): Well, looks like we have a Devil Fruit user here. That could be of use to us. I got a proposition for you. Either stay here and starve alone, or join up with me and we'll all be one big happy Donquixote Family. Don't be stupid, kid.
Law (looking down in defeat): Okay.
The flashback ends.
Law: I want you to know how it feels to have to watch people die all around you. I don't care if they're toys! After this, your whole operation will be exposed, the fruits, your harboring Caesar, your deal with Kaido, everything! Your life as Joker will be over!
Sanji: That's enough! Anti-Manners-
Law (very calmly): Countershock.
He catches Sanji's leg and shocks him, Sanji falls to the ground, stunned.
Franky (pointing all manner of weapons at him): Law, stop.
Law: What are you going to do? You know you'll cause too much collateral. I'll be back in a second, curtain!
He suddenly turns himself and the machine invisible, disappearing as if behind a curtain around a hospital bed. He returns a moment later with the machine, now silent, the glass ball now empty.
Law (grinning demonically): It's done. Now go, Doflamingo, go and experience the very thing I felt twenty years ago today. Some ruler you are. What kind of king stands idly by as half his subjects die? And those five other factories you mentioned? You're about to receive five very disturbing phone calls. Watch as the empire your father took years to build crumbles before your eyes in a matter of seconds. And even better, he gets to witness it.
Doflamingo: What? What are you talking about?
Law: Don't tell me your intel failed to tell you that CP-0 was on the island. And if my source is correct, the reason the most secret intelligence agency is mobilized is because the most secret wanted criminal is on the island. I guess he just wanted to pay his son a surprise visit.
Luffy: Wait, I thought my dad was the most wanted criminal.
Law: Normally you'd be right. Monkey D. Dragon is known to the public as the most wanted, but in fact he is second by a wide margin to the most infamous dark manipulator of global politics, Donquixote Delamancha!
In the center of Acacia, a man looks toward the factory and weeps.
Delamancha: What plague has been brought upon this once great land of fervor?