Symbolism, Imagery, Allegory
What do you call a moth that's not yet a moth? A worm, apparently: "A few days before school ended, Doon found the worm on the underside of a cabbage leaf he was slicing up for dinner. It was a pale soft green, velvety smooth all over, with tiny, stubby legs" (3.52). Because Doon's fascinated with insects of all kinds, he puts it in a box in order to study it.
At some point, between running around and trying to save the city, Doon notices that the worm has "wrapped itself up in a blanket of threads." (15.20) Now that's odd behavior for a worm, sure, but we can probably guess what's going on. And sure enough, while Doon is watching, the bundle begins to wriggle, and slowly, a moth emerges from it. This goes down right after Doon and Lina have figured out the Instructions for Egress and found the river path that leads out of Ember. So it's no wonder that Doon is all smiles as he watches the moth's transformation. Just like Doon and Lina will finally be able to escape Ember and change their lives for the better, the moth is finally able to escape it's cocoon and transform:
Doon watched until the moth disappeared. He knew he had seen something marvelous. What was the power that turned the worm into a moth? It was greater than any power the Builders had had, he was sure of that. The power that ran the city of Ember was feeble by comparison—and about to run out. (15.22)
Doon's on to something here. The fact that this transformation is so "marvelous" to him shows that he understands that nature is way more powerful than even the most powerful human. What this means to Doon (and the rest of the people in Ember) is that trusting in nature will get you farther than trusting in people. And don't tell the Believers we said this, but if nature is stronger than even the Builders, the citizens of Ember need to look to nature to guide them in the next steps of figuring out their world, just as the moth has done.