The routing on a computer network makes sure that information gets to the correct destination. Routing works like this:
Nearby computers are grouped together in a Local Area Network (LAN), in a group called a subnet. All machines on the same subnet know of all other machines on the subnet and hence can communicate. This is like a group of people in a room being able to pass messages to each other. To communicate with other computers outside the subnet, a gateway is required. This gateway knows where to send information based on the address attached to it. Using the analogy above, it would be similar to a postman standing in the doorway of the room who could take notes to another room. Of course, a room can have many doorways, and a multitude of postmen in the same way that a subnet can have multiple gateways.
The more networks a computer is on the more intelligent the routing needs to be. Internet routing is different, as there are so many possible route to decide between. For more details see How Stuff Works, as well as a great description from Shonky Internet’s “Systems Advisory Group”.