All planets start with a bunch of stuff orbitting around them, or in the same orbit around the sun that they are in. This can end up as rings or as moons, or as both.
There’s a distance called the Roche Limit. You can’t have a big moon closer to the planet than this, or it would get ripped apart by the difference in gravity from one side to the other. So chunks of stuff inside the Roche limit become rings, and moons which wander into this limit get ripped apart and become rings. The Roche limit depends on the size of the planet, so big planets are more likely to have rings.
All of the big planets – Jupiter, Saturn, Uranus and Neptune have rings, as does Venus. Mars has a moon Phobos inside the Roche limit, so the prediction is that it will eventually get pulled apart into a ring.
Venus and Mercury are too small to have moons or rings of their own. So is Earth really, but we got lucky.
Here’s a little bit more detail from wikipedia that I thought was cool:
There are three ways that planetary rings (the rings around planets) have been proposed to have formed: from material of the protoplanetary disk that was within the Roche limit of the planet and thus could not coalesce to form moons; from the debris of a moon that was disrupted by a large impact; or from the debris of a moon that was disrupted by tidal stresses when it passed within the planet’s Roche limit. Most rings were thought to be unstable and to dissipate over the course of tens or hundreds of millions of years, but it now appears that Saturn’s rings might be quite old, dating to the early days of the Solar system.
Some cool facts about Saturns rings: they are composed almost entirely of water ice, with some contamination from dust and other chemicals and are as thin as just 10m! Its amazing that we can see them so well! Have you ever observed them through a small telescope? Its pretty amazing!