Once upon a time, a looooong time ago, there was a big cloud floating around in space. This cloud was made up of gas and dust, kind of like when you sweep up dust bunnies. But this cloud was way bigger than any dust bunny you've ever seen - it was as big as the entire solar system!
Now, this cloud was just floating around, minding its own business, when something big happened. Maybe a star exploded nearby, or maybe two clouds bumped into each other, but whatever it was, it shook the whole cloud up. Suddenly, the cloud started spinning around really fast, kind of like when you spin around in circles and get dizzy. This spinning made the cloud start to flatten out, kind of like a pancake.
As the cloud flattened out, it started to spin faster and faster. And as it spun, the gas and dust in the cloud started to clump together, like when you roll a bunch of snowballs and make a snowman. Except these clumps weren't made of snow - they were made of rocks and gas and dust.
These clumps started to stick together and grow bigger and bigger. Some of them got so big that they started to heat up, kind of like when you rub your hands together really fast and they get warm. And when they got hot enough, they started to glow - they were turning into stars!
But there were other clumps that didn't get hot enough to become stars. Instead, they just kept growing and growing until they became planets. Some of these planets were big and bumpy, like Jupiter and Saturn. Others were small and rocky, like Earth and Mars.
As the planets formed, they started to clean up the space around them. They sucked up all the gas and dust that was left over, leaving behind just the rocks and debris. And over millions and millions of years, these rocks and debris smacked into each other and formed moons and asteroids and comets.
And that's how the solar system formed - from a big cloud of gas and dust that got shaken up and flattened out, then spun around and clumped together to form planets and stars and all kinds of other space stuff.