Terraria/WMG

Corruption is a manifestation of human evil
A long, long time ago, a Gigyas-esque monster of some description crash-landed in a metorite on a polluted, dying alternate version of Earth, destroying what remained of its biosphere and shifting its geological activity into overdrive. The humans retreated to what would eventually become the floating islands while mass earthquakes and volcanoes reshaped the earth into a shape unrecognizable to us, even when the magma hardened. The creature that arrived with the meteor drew power from human evil, and took a form representing it- specifically, the perversion of nature, hence the purple grass- and began to take over the dead world. It created the monsters that spawn in corruption to protect itself, and began storing power in the shadow orbs to sustain itself.
 * ...What about Hallow?
 * Terraria takes place in the same universe as Diablo 3?

Non-corrupted life in Terraria is genetically modified
After the catastrophie mentioned above, scientists on the floating islands went about creating life that could replace what was destroyed in the event. They eventually came out with several fast-growing, fast-spreading strains of plant life that reclaimed almost all of the Earth's surface in the years that came before the game itself. They also inserted direct copies of life that existed before the event into this replacement biosphere, but these animals had to eat something. The genetically engineered plant matter jump started their evolution- slimes are basically macroscopic bacteria, the worms are- well, worms- undead enemies are the result of parasitic organisms- zombie parasites evolved to replace the nervous system, while skeletons eat the remaining flesh and use it to construct a sort of muscular system in the bone marrow channels. Goblins are the descendants of those few non-islander survivors who had no other source of food. Why other animals are not there, I don't know. Mabye they were out-competed by the other organisms. As for demon enemies? Maybe they're just demons.

The world and the people who remain are what is left of a vast Magitech Society that Destroyed itself.
They developed a certain level of technology that allowed them to better interact with the magic that existed in the world itself. Societies that were enemies and competing for the resources that fueled this technology went to war. Things spiraled out of control and they destroyed their societies reducing them to a more primitive state compared the height of their technology.

The dungeons are various storage, living quarters, old labs, etc that are left over from the societies and the war. This is why they contain rare items.

Part of their tech involved using magic to change life to suit their own purposes resulting in things like the slimes and giant worms. The creatures like demon eyes and zombies are the end result of a mad scientist like campaign to make the ultimate weapon. The various boss monsters are the more powerful results of the experiments. Skeletron's "curse" is really a scientific experiment that had unexpected results and he is in fact immortal. The long life, knowledge of what he became and used to be as well as his part in destroying society, have driven him to the point of desiring destruction which is why he challenges you.

He is also guarding the most secure facilities to prevent the items inside from falling into the wrong hands. Believing anyone who will not free him from his curse has ill intentions is why he kills you if you penetrate the dungeon without destroying him first.

The various enemies in the dungeon are a back up security system powered by various Magitech experiments that protect what is left inside.

Enemies like demons and bone serpents are unique creations of the mad scientists and set to guard a potent resource that was likely used to fuel the war.

The war had additional side effects like unintentionally making multi-dimensional travel possible between the various worlds. This also affected the remaining humans. When they die it causes a form of paradox that the last scientist created a band aide fix to. The paradox resolves it self by returning you to key points in the world where you have left a form of "imprint". The reason you can respawn at beds is because when you have vivid dreams it makes a new imprint in the world.

As part of the effort to mobilize as much of their populations for war as they could, they implanted via magic and other means, the knowledge of engineering, design, manufacturing, and weapon usage. they also gave their people limited control of small pocket dimensions for storage as well as means to view it in their mind and recall the items into the world they are in currently.

As the effects of the damage to fabric of space and time of the world settle they will cause new biomes, items, and monsters to appear in the world. This also alters how far one can travel in the land.

The corruption resulted from an experiment with exotic manufacturing and storage with Magitech that went horribly wrong. The remnants of this are the dark orbs scattered about in pits where Magitech factories used to exist. The factories were powered by orbiting meteor that exerted gravity on an invisible beam of magic to the heart of the factories. Which is why when you smash them they come crashing to the earth as that interaction is the only thing keeping them aloft outside the atmosphere. The factory zones had Magitech creatures tied into the landscape around them which is why there are Soul Eaters, Devourers, and the Eater of Worlds atmosphere. The delay in destruction of the orb and the meteor falling is due to slowly decaying resistance of the beam once it's generator is gone.

The factories and the creatures which are powered by the same tech linked to the dark orbs emit a pollutant that causes the corruption. In their last ditch efforts to atone for their mistakes the remaining scientists modified the sunflowers to be powered by magic derived from sunlight to halt the spread of the corruption by cleaning it up in the areas next to the sun flower. They also developed the purifying powder to allow the survivors to make the land habitable again.

The Shadow Orbs are Soul Jars.
This explains the screams you hear when you break them, and why the Eater of Worlds gets PISSED and starts attacking you when you break the soul-pantries of the Eater of Souls. Alternatively, the Soul Eaters could just be harvesting the souls and, rather than eating them for sustanance, be transferring them into the Orbs to use as some sort of energy for the Corruption.

Source of magic/corruption is the stars/space,
Think about it. You can only gain mana from combining Fallen Stars into Mana Crystal. And destroying shadow orbs summons meteors. And Meteor armor regenerates mana and Space Gun uses mana.
 * The Hallow, on the other hand, is from the center of the Earth. The Wall of Flesh was it's seal, but guess who had to destroy it?

The corruption is trying to eradicate all magic.
The shadow pearls contain magical essences, the magical essences escaping causes meteors to fall, so when too much magic has been freed, the Eater of Worlds gets mad and tries to stop you from gaining access to more magical equipment. purification powder is also obviously magical.
 * The Hallow, on the other hand, is magic out of control, and just as bad-that's why Pixies and Unicorns live there.

The Meteors are solid magic constructs mined by the previous civilization.
The factories of the Magitech civilization, more than being fueled by the Shadow Orbs keeping the meteors aloft, were fueled by the magic of the orbiting meteors. When you craft armor and tools out of this solid magic by refining it, the inherent properties enhance and feed off of your own magical energies. The Corruption is the result of unshielded magic being siphoned down into the earth by the shadow orbs. Eventually using Meteorite tools and armor will result in you too being corrupted by its power.

Terraria is actually a 3-D universe.
However, two transparent walls have squished all terrain, blocks, and people into a flat plane of existence. The enemy mobs hate this, and attack everything they see because maybe it will undo the Curse of Two-Dimensionality. The NPCs enjoy their new, simpler lives and remain friendly.

And the Player Character is the one who cast the spell, all for your personal enjoyment.

The Corruption is an extremely short and wide herbivore.
It's slowly nomming the grass, which turns it purple, and it spreads through the cracks in stone very easily due to its odd shape. The little purple dots it gives off are spores for it to grow elsewhere. It also hosts symbiotic bacteria, which eventually group into Vile Mushrooms. If left unattended, the Vile Mushrooms hatch into Little Eaters, who slowly grow as they consume the corruption spores. Eventually, they'll group into Devourers, which prey on the smaller Eaters of Souls. In rare cases, the gases from a broken Corrupt Orb will instantly transform a well-fed Devourer into the Eater of Worlds, and it will go berserk from the sudden change. Otherwise, the Eaters of Worlds grow naturally from the Devourers, and spend time underground until they detect Worm Food and the presence of Corruption, when they attack.

There, I explained Corruption without mentioning magic OR evil.
 * The Hallow, on the other hand, is it's natural competitor-but far more magically based, instead calling Pixies and Unicorns from Another Dimension to defend itself. The Wall Of Flesh was a seal made by Precursors in order to prevent it from spreading again-both because it's just as finicky and because it's presence causes the Corruption to go into a "defense" mode where it spreads out of control in order to prevent the Hallow from out competing it.

The Guide is a somewhat benevolent Elder God in human form.
He is helping the protagonist in his quest to vanquish the corruption by giving him advice, he chooses not to use his powers to aid him/her for they are too terrible and mindbreaking for mortal minds. His purpose in doing this is not clear, perhaps he is at war with the other elder gods of Terraria and using the player as a means to an end, allowing him/her to do all the heavy lifting while he plots in the shadow.

Whenever he dies, he revives, often taking on a new name to avoid suspicion. However, the Voodoo Doll is one of his many life sources, taking the form of its current appereance. If the player holds it, The Guide's loses his invulnerability and can be killed, The Guide doesn't care, as he can always come back. But if the player destroys the doll by throwing it into the fires of the Underworld...


 * But considering the only way to bring about The Hallow is for


 * It could also be that, the power of The Hallow is set free, once bound by him for being a threat to his goals.

After The Hallow appears, the efforts of the lifeforms of The Corruption switch from random destruction.
Not many people realise that once The Hallow appears, it's just as rampantly infectious as The Corruption. We just tend to not notice it because it's pretty. But look at it from the point of view of the creatures of The Corruption - Not only is the weird blue grass stopping the growth of thier home, it's actually pushing it back. This could, if left unchecked, result in the end of life as the corrupted creatures know it. It gets locked in a bit of a stalemate, but...suppose if some adventurer went in and started helping the blue grass's growth...

The Wall of Flesh was the world's personification of balance.
Could it be that the Wall of Flesh was trying to protect the overworld from both forces, seeing them as a plague? While the Hallow was easily wiped out, the Corruption had enough power to linger, heavily restrained by it's surroundings. When summoned by sacrificing the Guide, the Wall of Flesh attacks, trying to preserve itself and the balance of the world. Once slain, it drops items that empower you, as if asking you to take it's place as the medium between good and evil. Hope you're up to the task.

Hard Mode is the Player redeeming themselves.
You get a lot of equipment pre-hardmode that seems evil (Demon/Necro/Molten). Maybe spreading the Hallow, and making Cobalt, Mythril, Adamantite, and Hallowed equipment is your way to atone?

The Goblins are well-intentioned extremists out to keep the player from destroying the world.
The goblins are generally content to completely ignore the player and let them go about their business... right up until the player starts trying to unleash the Eater of Worlds. This causes them to take notice of the player's activities and they start attacking them and their supporters to try to stop them from unleashing the Eater. If they fail, they try to keep up the pressure to hinder the player's goal of destroying the Wall of Flesh and releasing the spirits of light and darkness, which would make the Overworld virtually uninhabitable to anything that isn't a Hallow or Corruption creature. Even if they fail then, they'll keep attacking, often futily, to try and get rid of the player so they can try to re-bind the spirits and make the world safe for regular creatures once again. The Goblin Tinker is evicted for not agreeing with their extremism, and in turn joins up with the player once freed to try to thwart them.

The Hallow is exactly the same entity as the Corruption.
The only difference is that the Hallow is well-fed. The Corruption feeds on souls and gains power from them, but most of the souls and spirits were locked away in Hell, with The Wall of Flesh as their guardian. When this happened, the Corruption was greatly weakened, feeding off scraps of souls contained in the Shadow Orbs, and weak enough to be held back by rock and sunflowers. Without the souls, the creatures of the Corruption are forced to make do with consuming physical bodies without being able to take their souls. This allows them to grow bigger, but this barely increases their strength. The largest of the Devourers, the Eaters of Worlds, mostly stay in hibernation without the souls they need to sustain themselves, but when Shadow Orbs are broken, the released souls congregate around the player as they have nowhere else to go. When this congrgation of souls becomes large enough, an Eater of Worlds goes to consume them and fight the player in the process.
 * The demon altars are even greater repositories of souls, but they cannot be fed off by the corruption normally. But when Vile Powder and Rotten Chunks are forged into Worm Food,(as well as all other such items made in this manner) many souls are fused into the Worm Food, which is why it attracts the Eater of Worlds as well. This is the same for the Suspicious Eye, but the Eye of Cthullu does not wish to feed off the released souls, but instead return them to Hell to avoid the Corruption feeding on them.
 * When the Wall of Flesh is defeated, all the imprisoned souls are released into the earth, greatly feeding the Corruption. This makes it strong enough to overcome all natural boundaries once more and spead much faster. But some of the corruption feeds on so many souls it becomes saturated, and begins to exibit an aura which converts it into the Hallow. The reason why Corruption cannot spread into Hallow is because they are the same thing, but at different levels of nourishment. The massive increase in souls allow the Eaters of Souls and co to deform themselves into forms of even greater power, and the Hallow creatures are Eaters of Souls that are strong enough to transform into gilded bodies made of soul-stuff, though their true bodies are still rotten and vile underneath the sheen. Wyverns are Eaters of Worlds that have reached this state, gaining the power to fly in the process. And when the Demon altars are broken, so many souls are released from them that they crystalise into Colbolt, Mythril and Adamantite elsewhere, and if forged into weapons can be used against the Corruption/Hallow creatures, as they represent their very life force and as such can also disrupt and remove it.

The player character is a third force like the Corruption and Hallow, but in human form
The Corruption and Hallow are both powerful and evil forces dedicated to becoming more powerful and taking over the world, and halt each others' progress. The player character will clearly do anything to become more powerful (via increasing their maximum health and mana, and finding/equipping better and better equipment), including killing a man in order to summon an Eldritch Abomination just to ruin the world enough that better ore and items will appear. The Wall of Flesh was holding you back as well (though to a lesser degree), and killing it allows all three forces to reach their full potential; the Corruption and Hallow can spread more and get powerful monsters, and the player can get their best gear ind items. You halt the Corruption and Hallow just like they halt each other, by placing blocks they cannot infect and purifying/corrupting them with powders and seeds. The halt your progress with their difficult to mine blocks and dangerous monsters. Youy presence changes the landscape about as much as them; they fill the world with either thorns and purple grass or rainbows and turquoise grass, while you fill the world with buildings made of bricks, ore wood, and other blocks. Instead of merely changing the plant and animal life of the area like the Corruption and Hallow do, you change the basic shape of the land; destroying or building entire hills and lakes. The three forces are not evenly matched; the Hallow is weaker than the Corruption, due to its monsters; Hallowed monsters are not only weaker, but they don't have their own version of the Corruptor, which can spit slime that can turn other grass into Corrupt grass, including changing Hallowed grass. This is why there was no Hallow before Wall of Flesh was defeated; only you and the Corruption. The Player Character's strength relative to the other two is of course based on the skill of the player themself; it is theoretically possible to completely overpower both if the player is willing to spend enough time destroying every corrupt/hallowed block, or the world will be almost completely overrun if the player does not know how to stop them, but much more likely is that the three forces will be locked in a stalemate, with the player able to stop the Corruption and Hallow from spreading past certain points, and building within the area that is not corrupted/hallowed.

The Corruption/Hallow are equal, but not opposite.
The Hallow, besides being colourful, isn't much different from the Corruption. It takes over your world, destroying biomes besides itself, having strong monsters, and the trees don't drop acorns, preventing further growth. Think before you turn your world to hardmode...
 * In D&D terms, one could describe the Corruption as Chaotic Evil, and the Hallow as Chaotic Good, so not quite opposites, no. One might also consider The Player to be True Neutral in this case.

The Terraria!'Verse is another galaxy.
Originally, it was colonised by the Ancients, millennia ago. All was fine, until they awakened the Corruption, which then spread to every planet in this galaxy using the Stargates, forcing the Ancients to retreat to their spaceships, destroy the Stargates on those worlds, and drop down the Shadow Orbs, which are really tracking devices for weapons that fire incredibly large meteorites at where the Shadow Orb was smashed. Unfortunately, like everything else the Ancients did, that went wrong, and the Shadow Orbs didn't give the proper targeting data. So they sent down the Player, to try and activate the Orbs, which would allow the Ancients to wreak flaming havoc with their weapons, occasionally sending down a piece of technology here and there, to help you out in your quest. What they didn't count on was that the planets had their own security systems in place, set down by an even more ancient race. This was the Wall of Flesh, which kept the Corruption relatively in check. When the Player defeats that, the security systems would go into overdrive, creating the Hallow to attempt to stop the Corruption. However, without the security measures put in place by the Wall of Flesh, the Corruption grew even wilder, and spontaneously generated from nothing.

TL;DR - The Ancients colonised another galaxy, woke the Corruption up, which spread to all the other planets in that galaxy, so they sent down the Player, while giving him/her amazing technology to help this. The Wall of Flesh is a security measure set up by the even more ancient race that created that galaxy in the first place, and when defeated, stops focussing on controlling the Corruption, and releases the Hallow to control it.

The monsters are formed because of a god/goddess's emotional repression acting out by using his powers.
You character, or characters, even if not directly influenced/summoned by him, is a representation of the pressure exerted on the god's psych. You go around, and act either destructively or only to recreate the world. Corruption is caused by the god's anger/regret. Gods, being proud creatures, tend to repress such emotion as it doesn't paint them as perfect. The eaters are doubt, slowly nibbling at him. The chasms are his depressions/mental scars. Things the god did that left a very deep impression on him, such as getting told that they would never be with someone they want by that person, or killing somebody blindly only to find out that they were huge supporters of them beforehand. The shadow orbs collect in response to suppressed memories, not repressed by put into a manageable size while still being acknowledged. Breaking them represents forcing them to become unsuppressed, but seeing as we are not a Psychonaut and thus not in the god's mind it has no real effects other than materializing an item from the memory, the gun representing power or struggle or the thorn being hurting or killing somebody. The eater of worlds attacks because it come into being as a large representation of doubt, so breaking would key to to think that the host is getting depressed, and trying to feed on it when in reality it's just attacking a person.

deep underground represents anger, going from "I'm annoyed but can ignore it" to "I'm going to ****ing rip you in half!" In hell, the demons are manifestations of anger, where voodoo was made of anger concentrated at someone, rather than a group, and as the guide was the first one there, apparently, he was the sculpt for the doll. Throwing the doll in summons the wall of flesh because the doll burns up right away, rather than a problem solved the power assumes that it was someone who escaped punishment unharmed. Being the key for "failure", it summons the wall of flesh as the god's full anger. The wall of flesh is the god's shapeless anger. Attacking you because of spite, but because like all the other large bosses it is still attached to the god's psych. When you kill it, the god's power shifts feeling such a sudden change, and it goes to trying to suppress both his good and bad emotions, getting a quick glimpse at what his suppressed anger looks like. That's why hard mode comes in, because the god suddenly starts releasing an influx of magic with his new mental state, let's assume they got drunk when they made the decision. The hallow becomes the suppressed good emotion, but because it's still suppressed the creature that spawn from it, normally hopeful, are angry at being locked away.

Blood moon is a moment of emotional stress, taking place over the whole night. Shadow alters are suppressed want/lust. Breaking them releases the feeling that will soon affect metals making more magical one. Sky towers are pride, good items held high above all else. biomes were part of the natural world, and not part of it. Monsters represent forms of stress, such as trying to remember something. The NPCs are other people who happen to come to the place. The sunglasses are so awesome that the god feels need to make the sun acknowledge this.

The creatures of The Hallow used to be gentle and mild around humans before they and their biome dissappeared from the world.
A long time ago, The Hallow was a powerful and mystic enviroment which welcomed travellers and offered them susteinance, but it was then exploited, erradicated and bound to The Wall of Flesh for all eternity, an attrmpt by those who came before to obtain more mahgical power. The player then frees it, but it doesnt act grateful torwards the player for helping it. THe Hallow's previopus experience made it lose all trust on humanity, and now responds to your mere precence with merciless hostility

The Guide is the avatar of a god, entrusted with the power to keep the Hallow and Corruption under control.
Long ago, two great powers, the Hallow, and the Corruption, clashed for control of the world. Eventually, the people of the world begged for help from anyone, anything. So a third power rose up and attempted to seal the two. It sealed the Hallow first. However, the two powers were mightier than it. By the time it sealed the Corruption, it was weakened to the point where a bit of corruption slipped through the cracks. This is where the guide comes in. The third power, which manifested as a pillar of flesh due to its connection with mortals, chose a worthy human, a knowledgeable man, to be it's avatar. The man was granted immortality, and as long as the two were linked, the Hallow and Corruption could not escape to ravage the world. And so, the man remained alive, safeguarding the world for thousands of years. At one point in time, demonic cultists discovered the secret to his immortality and created magical representations of him which allowed the wielder to slay him. Thanks to the god's powers, the man would reincarnate instantly, and only the fires of hell could break their link. And if the link was ever broken, the world would be in grave danger once again. And then, you, the player, murder the guide in the flames of hell. The god manifests as a last-ditch effort to protect the world, so you kill him just for a bit of treasure. You'd better be stopping the Hallow and Corruption, or the world is doomed and it's all your fault. Good job.