It seems that it didn't actually protect them from any form of attack.
Every direct hit from a laser seemed to kill a stormtrooper outright, and a slice from a lightsaber cuts straight through.
"Every direct hit from a laser seemed to kill a storm-trooper outright, "
Not necessarily true. We see troopers being hit by laser fire and falling, but we don't follow any of them to learn their actual fates.
As Wookieepedia explains in greater detail, some of the basic protections the armor affords includes:
In the old West End Games Star Wars RPG (which was considered low canon) Stormtrooper armor is actually fairly good. It provides something like +2 resistance against energy weapons and +2D against physical.
This means that when you rolled to soak damage from a blaster, you added 1D6 to your roll (for an average stormtrooper, that would make it 4d6). Against physical, you added 2d6 (making it 5d6 for an average stormtrooper).
This sounds impressive (4-26 points of damage soaked) until you realize that Han's blaster (a heavy blaster pistol) deals 5d6 damage, and the blaster carbines and rifles that other characters use deal 5d6 damage as well. Lightsabers start at 5d6 damage, and add damage based on your force abilities. Pretty much any energy weapon does the same (or more) dice worth of damage as a typical stormtrooper (in armor) can soak. This gives a stormtrooper about a 50/50 chance of taking damage from any shot from the weakest blaster.
The long and short of it? Stormtrooper armor isn't that effective, it's just the best there is (in common usage).
Much like modern body armor isn't able to stop typical assault rifle AP rounds at typical distances, stormtrooper armor isn't designed to make the wearer invulnerable. It just serves to absorb some of the damage and give you a better chance at surviving.
Mandalorian Armor used Mandalorian Iron, which used a special refinement technique that was lost to the galaxy at large with their defeat at the end of the Mandalorian War (Boba Fett's armor was likely worth a bantha's weight in gold).
Also, the empire, as several above posters pointed out, equipped storm-troopers by the billions. There were roughly 1.7 MILLION worlds under imperial control, the total garrisoned strength of the storm troopers would have bankrupted the empire to equip in high-end mercenary armor. That being said, they did have elite corps like the imperial guard and shadow troopers that were supposed to have better armor. As for storm-troopers, even us issue isn't truly top-of-the line, it's common knowledge that low-bids are a HUGE consideration in who the senate picks to get the contracts to supply the military. And that is in the US, where human rights and lobbyists work to promote the value of a soldier's life.
Now, take the empire, whose battle strategy in space combat was "throw swarms of the cheapest, fastest, unshielded guns with cockpits against the enemies and they'll go down eventually". The life of their soldiers was obviously not a top resource priority. Storm trooper armor would be the least expensive way the empire could find to field as many troops as possible in as many different environments as possible. The empire spent money on WMD and terror; death stars, clones of the emperor, star destroyers, at-ats, super star destroyers. They did not spend money on individual frontline troops.
I always assumed that the Trooper armor was part of an all-purpose enviromenal battle suit. If you think of it in terms with our own bulletproof vests that police wear, or the Improved Ballistic Armor (IBA) that coalition forces wear, then it is there to improve the chances of a wearer's protection. The original flak jackets were made for shrapnel, and had insertable metal plates that stopped pistol rounds, while we now have plates that can stop military-grade rounds.
Yeah. Nothing's foolproof.
If you also think of what the Star Wars weapons are capable of (blasters are essentially particle accelerators, while lightsabers are high-frequency tight-beam energy swords), what could one use to protect against as such? Practical armor probably isn't practical; too bulky, too heavy, etc. Remember that we've had bullets for a lot longer than we've had a means to personally protect ourselves from them. You would think that a protable deflector shield would be rather standard issue, as the Gungans had them in the Battle of Naboo.
Here is evidence that the armor offers some protection. In line with phantom's answer, the energy blast gets dispersed although the trooper may be knocked out for a while.
In the canon Clone Wars cartoon series (S2 E10, "The Deserter"), Rex gets shot just below the neck but survives. You can see the black mark on his suit. Given that the sniper rifle used on him is more powerful than a normal blaster, I'd imagine that the armor is probably reasonably effective.
The new canon novel "Battlefront: Twilight Company" shows that stormtrooper armor is not necessarily as vulnerable as may be perceived by the films / tv series as several protagonists mention / think of the armor as strong and forbidding (too many instances to cite)
Additionally, the armor has recording capabilities that can be used to reprimand (or possibly reward) soldiers:
"When her armor's memory was downloaded, she'd probably be caught, her indiscretion flagged and automatically appended to her record"
"You know that stormtrooper armor has environmental controls? Internal cooling options?"
In addition to (most of) the above answers, one must remember that the Empire needed to maintain uniformity among its ranks. The Stormtrooper armor, as well as the armors of their more specialized units, served both as protection and as a symbol of unit and rank structure.
Additionally again, it made certain that Imperial units were identified by the populace, and the black-and-white style of the armor became a symbol itself. It almost acted as it's own propaganda for the Empire.
They wear armor because it looks cool, just like how the Polish Zouaves of Death wore red fezes with their black uniforms.
The great thing about making Science Fiction movies is that if they catch on, people will devote hours of their lives to justifying incongruities that were clearly meant to be overlooked for the sake of story-telling in a visual medium.
ST armor is like today's armor. Gives a chance at survival. It's not meant to deflect rounds like they are nothing. It's meant to allow you to survive, not necessarily be totally unharmed. A 7.62 striking you in the chest will stop you dead, and knock you over. Ceramic strike faces will provide one hit protection. The ST armor works the same way. You don't die, good enough. You would have injuries, but SW medicine allows for quick healing.