How much does it rain in Perth in a year?

The annual rainfall of Perth is 790 mm, which is about 31 inches.

In answer to your question "why does it rain", it rains because water evaporates into the air, until the air contains more water than it can hold as a gas. When that happens, clouds form. As clouds get cooler, the water droplets in the cloud get larger and fall as raindrops (or hail or snow).