There was enough "stuff" left over from the nebula to form all our planets. As the protoplanets started to form and got more massive they started to "clean" up what they could...Jupiter was the hog of course.
Scientifically, gravity from the sun attracted the planets. It is incredibly difficult to escape from the gravitational pull of a large star, such as the sun. Religiously, God put it there because he deemed that it was perfect
Psalm 19:1 says that "the heavens declare the glory of God, and the firmament shows His handiwork." Everything that God has made, be it you and me, or wildlife, or angels, or stars and planets, has been created for His glory. When we see a breathtaking view of the Milky Way or peer at Saturn through a telescope, we are amazed at the wonders of God!