The timer hardware
The chip's clock ticks 16 million times a second. An 8-bit counter fed straight from it would fill up every 16 µs. That is too fast to be useful for counting milliseconds, so we slow the ticks down first.
A prescaler is a divider in front of the timer. The Arduino core sets it to 64: one tick passes for every 64 clock ticks. So the timer gets 250,000 ticks a second, one every 4 µs.
Each slowed tick adds 1 to TCNT0, Timer0's 8-bit counter register. This is hardware: no code runs to count, so the CPU stays free to run your program. It counts 0, 1, 2 ... up to 255.
After 255 the counter rolls over to 0. That is an overflow, and it sets a flag bit, TOV0. It happens every 256 × 4 µs = 1,024 µs, slightly more than one millisecond.
The millis() interrupt
The core enabled the overflow interrupt, so the flag makes the CPU pause and run a short function, an ISR. It adds 1 to ms and 3 to fract. Hardware clears the flag, and your program carries on.
Each overflow is 1,024 µs, not 1,000. fract keeps the extra 24 µs, in steps of 8 µs, so adds 3. When it reaches 125, a whole millisecond has built up: ms gets one more. Here 41 becomes 43.
Using millis()
millis() just returns ms. ms is 4 bytes, and the ISR could change it halfway through a read, so millis() turns interrupts off for that copy. The lesson "volatile and sharing data with an ISR" explains why.
loop() checks the time and moves on. When now - last reaches 500, it flips the LED and adds 500 to last. No delay(), so the rest of loop() keeps running between blinks.
ms is an unsigned long, 32 bits, so after 2³² ms, about 49.7 days, it rolls back to 0, like TCNT0 does. now - last still works: unsigned subtraction wraps too, so 204 - 4,294,967,000 gives 500.
What happens
;; step 1/9 · clock clock 16,000,000 ticks per second (16 MHz) one tick 1 / 16 MHz = 0.0625 µs 8-bit counts 0 .. 255, so 256 ticks fill it 256 x 0.0625 µs = 16 µs: far too short
The cards rename the core's timer0_millis and timer0_fract to ms and fract, and fold its MILLIS_INC (1), FRACT_INC (3) and FRACT_MAX (125) into plain numbers. The real ISR also counts overflows for micros(). Timer0 belongs to millis(), so for your own timing use Timer1, a 16-bit timer. In CTC mode it clears when it matches OCR1A: with prescaler 1024 it ticks 15,625 times a second, so OCR1A = 15624 gives exactly one interrupt per second.