A hub is a simple 'port amplifier and replicator'. Any data on any port is simply buffered, boosted and re-distributed to all the other ports.
A Router is more intelligent and uses IP addresses to determine which port to send data to. Technically, routers are faster as traffic on each port is only intended for that port and there is no need for a node to listen to all traffic and look for the data it is after.
For example, on a 4 port hub, all data transmitted and received is available on all four ports, whereas on a router data on port 1 intended only for port 2 is sent only to port 2. Ports 3 and 4 do not have this data on them and so can carry other data. This helps to avoid collisions. Where more than one data path is available,a router can also determine the optimum path for fastest data transfer.