The Second Foundation was created to monitor the progress of the First Foundation using the tools of psychohistory and compensate for unseen factors (such as The Mule and Daneel's Robots) using their mentalic abilities. The Second Foundation was based at Star's End, a secret location that I won't reveal incase you haven't read the great book of this name.