Routers connect subnets
A router has an interface in each network it joins. When a packet arrives, the router looks up the destination in its route table and forwards it out the right interface or to the next-hop router. A router only forwards to networks it knows about.
Connected, static, and default routes
A router automatically knows its directly-connected subnets. For anything else it needs a route: a static route ('to reach 10.0.3.0/24, send to 10.0.2.2') or a default route (0.0.0.0/0 - 'everything else goes this way', typically toward the internet).
Longest-prefix match
When several routes match a destination, the most specific one (longest prefix) wins. A /24 route beats the /0 default. If nothing matches, the packet is dropped - 'no route to host.'