Hari Seldon devised the Seldon Plan using an analytical technique he had mastered called psychohistory. His analysis worked only for large numbers of persons, working as a mob, unaware of their likely future, and gave probable paths for wider historical developments. Using this technique, Seldon deduced that it was certain the Galactic Empire was about to collapse, and usher in 30,000 years of barbarism.
The basic concept behind the plan, was initially stated to be to reduce 30,000 years of Galactic barbarism, to under 1,000, and establish a Second Galactic Empire. This appears to have been the original version of the plan. Not because Seldon did not have wider aspirations, but because that was as far as it was originally worked out by Seldon himself.
Seldon obtained permission from the Emperor to start an Encyclopedia project, on a planet towards the outer edges of the Galaxy, that was resource poor. This 'Foundation' was to face a series of crisis, that would typically have one likely outcome, the Foundation was forced to take each time. For example, the lack of metals, forced the Foundation to co-operate and trade with neighbors. Each time a major crisis happened, a projection of Seldon would appear, and make comments on the situation that had just passed. After the first crises had passed, Seldon revealed the secret purpose of the Foundation was to re-create the Galactic Empire.
As the novels progress, the reader learns more of the Second Foundation, composed of mental rather than physical scientists. These Second Foundationers have the power to manipulate minds, to shape the course of the development of the First Foundation (often referred to simply as the Foundation). This leads to strife between the two Foundations, as seen in Second Foundation.
The Second Foundation agent Chanis states on page 78 in Second Foundation:
So he (Seldon) created his Foundations according to the laws of psychohistory, but who knew better than he that even these laws were relative. He never created a finished product. Finished products are for decadent minds. His was an evolving mechanism and the Second Foundation was the instrument of that evolution.
In chapter 8, we get more details on how the Second Foundation maintain the plan, a complex series of mathematical models, kept in the Prime radiant.
The Seldon plan is neither complete nor correct. Instead, it is merely the best that could be done at the time. Over a dozen generations of men have poured over these equations, worked at them, taken them apart to the last decimal place, and put them together again.
In this chapter the wider scope of the plan is revealed to the reader, and it is stated the purpose of the Second Galactic Empire, will be to accept a ruling class populated from the mental scientists of the Second Foundation. Without control of emotion, the models show all Galactic Empires will ultimately fail, regardless of the level of technology.
The plan came close to failure in Foundation and Empire because of the mutant called The Mule. Because the Mule had psychic powers of mind control, he did not fit the model of interactions psychohistory was based upon. The Mule could influence men at a distance, unlike Second Foundation agents, who required eye contact. The Mule was eventually lured to a remote planet to destroy the Second Foundation. However, in so doing, he left his main fleet, which was turned against him by Second Foundation agents in his absence, thus ending his rule.
In Foundation's Edge and Foundation and Earth, the reader, as well as certain characters in the novels, learns of another world called Gaia, a planet of humans who all share a collective consciousness. Strangely, they seem to be fostering the Seldon Plan similarly to the Second Foundation. However, they seem to have a much more subtle, and complex, understanding of the final nature of the Seldon Plan. If this is true, it would seem that Hari Seldon hid some of the true nature of the plan even from the Second Foundation.
It should be noted that finding a complete canonical reference for the Plan is difficult. Asimov admitted that he wrote the last two novels due to reader demand, not entirely of his own volition. Thus, he may have made significant changes to his original vision, as set forth in the Foundation trilogy. He also made efforts in Foundation's Edge and Foundation and Earth to tie the books into his Robot and Empire series. This can, at least somewhat, account for some of the discrepancies that the reader finds in the literary development of the plan. Eventually the Seldon plan was abandoned in favor of the giant super organism Galaxia. However, later works by other authors suggest that the great second empire could be a powerful combination of the two possibilities.
All the above is taken from the Foundation Series novels, including at points both chapter and page number references.