A router is a piece of networking hardware and functions to connect multiple networks or devices and routes traffic between them. They also serve as the first line of defense from intrusion from the internet. A router is also responsible for assigning IP addresses to computers or devices connected to the local network. They typically operate off of firmware that is released and updated by the manufacturer of the device.
While they are mostly thought of as being the intermediary between the modem which transmits to the internet and a device like a laptop, they also serve other purposes. They can connect multiple devices in local network. An example of which is multiple computers in the same building that share a printer through the network. They also allow multiple networks to connect expanding its reach.
Devices can connect to the router either wirelessly (using a wireless router) or by connecting devices to the router using cables. Advancements in wireless router and networking technology have made the wireless option more popular for both the ease of mobility they provide and reduction in the reliance on cables. Most wireless routers also provide the ability to make a wired connection also.