I heard a layman's answer to this question on a Discovery Channel show several years ago.
The theory of how the endoskeleton evolved went like this:
Small chordates, such as Pikaia and Amphioxus, were constantly being hunted by large, vicious predators like Animalocaris. "Oh no!" screamed Pikaia, "It's an animalocaris! Run for your AAAAAAGH!" <chomp>
How did Pikaia escape extinction when faced with such a menacing beast? It found an environment where Animalocaris couldn't touch it. Instead of taking his chances in the predator-infested oceans of the Paleozoic Era, Pikaia hid out in the less-salty, more-brackish waters at the mouths of river deltas. The farther into the unsalty water he could swim, the better the chances were that Animalocaris couldn't follow him there.
But with his new found safe haven, Pikaia had a whole new set of problems. For example, the cyptolasm in Pikaia's cells had a salinity very close to that of ocean water. The brackish less-salty waters he now found himself in, though, would make his salty cells swell and burst from osmosis if he couldn't do something about it. The solution? A kidney! A new, specialized organ to take all the extra water that was working its way into Pikaia's bloodstream, and pump it back out into the environment. Pikaia's descendants invented peeing.
But not having enough salt in the water he was breathing wasn't Pikaia's only problem. The deep ocean waters are home to many, many vital minerals besides salt -- magnesium, calcium, copper, you name it. The brackish waters around the mouths of rivers simply didn't have a high enough concentration of these minerals to sustain Pikaia, particularly with all that peeing he was now doing.
What to do? Why, he could store the minerals somewhere in his body when they were plentiful and he was at rest, so that he could use them later. The most obvious place to hang these collections of stored minerals was his notochord, the nerve cord that ran the length of his body and gave his phylum its name. And so, what was once just a long bundle of nerves now began to accumulate a long chain of rocks around it, consisting primarily of calcium since that was the one mineral Pikaia needed the most of.
These notochord-hanging mineral deposits were what eventually became the Backbone as we know it. They were the first bones to evolve. We owe the great structural strength of our arms and legs to a nutrient storage system, chanced upon as a solution to the problems of permanently escaping from predators.