Scientifically, the planets in our solar system formed over millions of years from a massive cloud of gas and dust. This process is understood through theories like the nebular hypothesis.
If you're interested in understanding the scientific perspective on the formation of the solar system, I recommend researching the nebular hypothesis or other scientific explanations for planetary formation.