In a Nutshell:
Routers break up Broadcast Domains, Switches break up collision domains, hubs simply broadcast data (repeaters).
The importance of the Layer 2 and Layer 3 deals with encapsulation and addressing. In a simple form: A Router looksat the Network Layer (IP address, etc ) and directs data. The switch looks at the MAC address. The switch is basically an advanced hardware bridge (with a few extra benefits). What this means to you is that the router can route data to different networks. The switch creates multiple collision domains to enhance network bandwidth utilization. The Switch can transfer data to machines on the network that it knows the mac address info for (or can broadcast the data if it doesn't know the mac).
The router can look at the network data and send it to the appropriate network if it's not on the local one. Not meaning to make this confusing, but there are Layer 3 switches too...but they really are combo router/switches.
A gateway is basically a door to "outside" networks (like on a WAN or the internet). The idea is the Router is told "If you don't know where this network is, ship it out this port. The idea is the routers will keep relaying it until it hits the one that does know where thenetwork resides. This is in essence what the "world wide web" is....
A hub can only broadcast data to all the connected ports. It is a Layer 1 (physical) device and simply a repeater. The switch works on Data Link MAC filter tables. Neither work on the network layer which is used in transmitting the data to the internet via cable/dls etc. You *can* share your internet access without a hardware router, however. If you use ICS, or set up a second NIC with NAT translation/IP masquerading, that will act as a software router and you can then share your broadband connection.