Dios is not a stable time loop
Somewhere in his future, he is forced to adopt a human who ends up practically (and possibly literally) living in the scripts. The elder is killed by a collapsing pyramid or something, and the "apprentice" takes up the post of Moderately Appreciable Vizier.
Dios is the Spirit of Djelibeybi.
Dios was called into being as a deliberate part of Djelibeybi's creation by Khuft's camels.
Because who'd be more inclined to field-test the recursive nature of space/time than a bunch of genius theoretical mathematicians? And who, if not camels, would reason that if you want humans to start work on hayfields and stables, you need somebody to prod those lazy apes with a stick?
The Great Pyramid's detonation, not the History Monks, is to blame for the time-displaced philosophers in Small Gods.
Ephebe is close enough to Djelibeybi to travel there within less than a day on camelback, and we know that blowback from its detonation sent Dios back 7000 years. Prior to this, we see the Great Pyramid not only twisting time and space, but absorbing the flares of temporal energy from neighboring pyramids. So when Teppic inhumed the thing, it actually contained more accumulated time than even it could hold, and it spewed these surplus energies out randomly in all directions, beyond even Djelibeybi's borders. While the Men In Saffron might indeed have acted to tidy up much of the resulting mess, a random burst of temporal flux struck the tavern where Xeno and Ibid were debating over lunch, and swept them back a hundred years into the past, to appear in Small Gods. (Being, y'know, Xeno and Ibid, they may or may not have noticed the difference.)
Please do not add a WMG markup unless the individual Discworld book pages are added to the main WMG index or another work shares this page.