Let's start by discussing how clouds form. The air around you is full of water in its gaseous form, called water vapor. When the air near the ground warms, it starts to rise, taking the water vapor along with it.
The air starts to cool as it rises higher into the sky, causing the water vapor to condense onto atmospheric dust from volcanoes, car exhaust and other sources. The resulting water droplets and ice crystals coalesce, or join together, to form clouds.
Unlike atmospheric particles that scatter more blue light than other colors (making the sky blue), the tiny cloud particles equally scatter all colors of light, which together make up white light.
However, rain clouds are gray instead of white because of their thickness, or height.
That is, a cloud gets thicker and denser as it gathers more water droplets and ice crystals — the thicker it gets, the more light it scatters, resulting in less light penetrating all the way through it.
The particles on the underside of the rain cloud don't have a lot of light to scatter to your eyes, so the base appears gray as you look on from the ground below.
This effect becomes more pronounced the larger the water droplets get — such as right before they're large enough to fall from the sky as rain or snow — because they become more efficient at absorbing light, rather than scattering it.