The main question I have is, how exactly does a computer know where to send an internet request?
It all has to do with the routing table of the computer. Basically the sequence of events goes roughly like this:
1) The OS's TCP/IP stack examins the destination IP and attempts to match it up to some entry on the routing table. Essentially this is the 'Is it local or not' step.
2) Assuming the address is not local, it typically goes to the default gateway. If you have a LAN, then it would end up at your local router, which most likely would just send it on to the ISP's router. If you don't have a LAN, then it'd just go directly to the ISP's router.
3) The router goes through a process similar to what your PC did. It looks at the destination IP and matches it to a route in it's routing table. If it matches one, it will send the packet down that route. If it can't find a match then the packet goes up to the next router in the chain. This process of passing up to a higher-level router repeats until a match is found (or there are no more possible routes).
As for how the PC and router determines which route the IP is a part of, this has to do with the Netmask. A route basically defines an IP prefix and specifies which port belongs to that prefix. So for example say your ISP's router had 5 ports, each connected to another network.
Lets assume the ports are connected like so:
Port 1: 192.168.10.100/24
Port 2: 192.168.20.100/24
Port 3: 192.168.30.100/24
Port 4: 192.168.40.100/24
Port 5: 192.168.50.100/24*
The /24 part in the above is the netmask, specified using CIDR notation. With the values I chose it basically splits the IP at the last dot so the first 3 sections denote the network, and the last denotes the host. Assume the * denotes the default route/gateway
If the router gets a packet destined for 192.168.45.203 then it would attempt to match that IP up to it's various routes. First it will take that destination IP and break it down to just the network portion, which is: 192.168.40. Then it will go through it's routing table looking for a matching network entry. In this case, it finds one on Port 4, so it would forward that packet out to whatever is connected to Port 4.
If the router would have been unable to find a match (say the destination IP was 192.168.100.48), then it would forward the packet to it's default gateway, which in this case is 192.168.50.100. Then that router would repeat the process until a valid route was found.
Once the packet reaches the destination network,a port (in this case most likely port 80) forwards it to the host
Not exactly. The IP is what determines the host. The port indicates the service. So it would make it to your computer by IP address alone. Once it has reached your computer, the OS accepts the packet and examins it.
The OS looks at what service (port) the packet is destined for and then checks it's records to see if any process is expecting packets destined for that service (ie, apache). If so, it will pass the packet on to that process
which then pickes it up and does whatever. If the OS can't find any processes that will accept that packet, it generates an error response and sends that back to the original packet sender.
That is essentially the super-simplified basic understanding of how networking works. There is potentionally a lot more going on, such as NAT's, Firewalls, Tunneling, etc. NAT's may be causing you some confusion, evidenced by a couple things you mentioned: "a port ... forwards it to the host"/"and somehow remembering which device requested it".
Involving NAT is what introduces the need for port-based forwarding of packets, which requires the device to remember where packets originated from. If you're behind a NAT, when you send a packet out, the router will take note of that packet's source IP and port #. It then re-writes that bit of the packet with it's own IP and port # and sends the packet up the chain. When a reply packet is recived the router will check it's destination port# and try to match it up to it's list of sent port numbers. If it finds a match it will re-write the packet with the proper destination IP and port and forward it on. If it doesn't find a match the packet is usually just dropped. Go to the full post