A router is a networking device which operates at layer 3 of the OSI Model. Its purpose is to switch data packets between its various interfaces based upon the destination IP address of the packet.
Routers are intelligent devices and can make decisions about which route a packet can take through a network if there are multiple paths possible. The decision about which path to take is made from a link's cost which is calculated from the factors of bandwidth, hop count, financial cost, load, delay and reliability.
Many routers also provide a service known as Network Address Translation or NAT.
It should also be pointed out that from a security point of view, if you have a router, then every computer behind it is protected from attack from the other side (i.e. the internet). However, this does not protect you from accessing viruses or other malware on the Internet and infecting your machine with them. It only protects against direct attack from the other side of the router.