i'm not certain, but i've always assumed it was based on tire rotations. you know the circumference of a tire to a fairly good estimate.
let's say the tire has a 3 foot circumference (that won't be the actual number, but it's good enough for an example).
3 feet * number of times the tire has gone through a full rotation * 1 mile/5280 feet = miles the car has been driven.
you can do that digitally or you can set up a mechanical gear train to do the conversion for you.
not certain that's how it's actually done, but that's how i'd do it.
Paul