There are a great number of line encoding schemes which deal with different special cases. I'm just going to talk about the simplest ones.
At base, don't think about it like software: "we keep checking it to see if it changes". The electronics is more like a spring which is unhooked when an event happens, such as a voltage exceeding a certain level. Or pushing something off a table: it doesn't "keep checking" to see if there's something under it: there's a force stopping it moving downwards. When the force is removed, it falls.
The simplest line encoding in common use is NRZ ("non-return-to-zero", a name which doesn't help much until you already understand it.) This is used in RS-232 and many other things. A line is at some voltage, say 5V. When it falls below say 1V, we start a timer. Suppose the bits are going to be one per second: we start a timer for half a second -- we should be in the middle of the here-comes-a-byte "start bit". After this half a second, we wait another second: now we're in the middle of the first bit: we just check the voltage. Wait another second, check the voltage and we have the second bit. Do this eight times till we have a byte.
You'll see that process is built of three mechanisms:
- waiting until an event occurred (voltage falling below a value)
- waiting a fixed amount of time (half or whole bit time)
- sampling the line at a given moment
That process normally happens in hardware, but sometimes firmware. All the details vary: the voltages, the speeds, whether high voltage is a one or a zero, whether the first bit is the low-value or the high-value bit. See Wikipedia for more.
It's true that the first of those (wait until signal is low) could be done by a processor sampling at speed. But it is more usually done by circuitry which performs an action after an event, perhaps by the signal feeding a latch which holds some timer chip in reset.
Once we have bytes there will be some scheme to get framing, of which the simplest is SLIP (serial line protocol), where, in essence, a particular byte value indicates the beginning of a frame. There's nothing like reading the real RFCs which define the internet, and the one which defines this is especially simple RFC1055.
There are very many other schemes for framing, such as "long time without signal" (used in DMX) or "no voltage at all means not inside a frame" (used in coax ethernet).
Ethernet is akin to the mechanism described, but much more complex. Especially the faster kinds, which are very much more complex. The simplest in current use is 10baseT, which uses "Manchester Encoding" (named after the university where it was developed). The basic idea is the same: wait for a particular type of transition, then wait a certain period, take a sample, repeat. But every detail is different. Wikipedia has a good article.
As said in comments, whole books on the subject of encodings: whole PhDs.
High performance framing and encoding schemes are all about
- errors -- what happens when noise or other problems mean the received signal isn't what was expected
- bandwidth -- how to get the most bits down the channel that we can
- money -- how to do it with cheapest materials
- reliability -- how to use parts which don't break
Seriously: if you understand RS-232, NRZ, SLIP, and that proper networking is much more complex, you know enough for a networking person. It's much more important to know about which kinds of networking have link detection than the details of how they work.
If you want more detail about how the circuits work, electronics.stackexchange.com is probably a better bet than here, but we're good for things like framing and CRC errors and similar.