The planets in our solar system generally rotate in the same direction, which is counterclockwise as viewed from above the Sun's north pole. This is known as prograde rotation. There are a few factors that contribute to this consistency in the rotation direction.
Formation from a rotating disk: The planets in our solar system formed from a rotating disk of gas and dust known as the protoplanetary disk. As this disk gradually collapsed under the influence of gravity, it conserved its overall angular momentum. The angular momentum caused the material to rotate around the forming Sun in a specific direction. The planets, which formed from this rotating disk, inherited the direction of rotation.
Conservation of angular momentum: Angular momentum is a fundamental physical property that is conserved in the absence of external torques. As the protoplanetary disk contracted and the material came together to form planets, the overall angular momentum of the system remained roughly constant. This conservation of angular momentum played a role in determining the rotation direction of the planets. Any initial rotation of the forming planetesimals or the collisions between them contributed to the overall angular momentum of the planets, leading to a consistent direction of rotation.
It's worth noting that there are some exceptions and variations in the rotation directions of certain celestial bodies in the solar system. For example, Venus has a retrograde (clockwise) rotation, and Uranus has an extreme tilt that causes its rotation to appear sideways. These exceptions likely resulted from later disruptive events, such as large impacts or gravitational interactions with other bodies, that caused changes to their original rotation patterns.
In summary, the consistent rotation direction of the planets in our solar system is primarily due to the initial angular momentum of the rotating protoplanetary disk from which they formed and the conservation of angular momentum during their formation process.