All rooms periodically reset themselves to the state that they were in when the Doctor arrives. The system cannot tell that a new iteration of the cycle is not the Doctor arriving for the first time, and so reverts to the way things were when the teleporter last resolved/the most recent copy of the Doctor was loaded.
The first time the doctor arrived, we know things did not play out in the same manner as we saw - no-one would have written 'bird' in the sand, for example. We also know that it takes around a day and a half for the doctor to expire after being caught by the Veil. The rest is speculation: after the Veil deactivates, the cycle is over, and the castle will no longer reset. 'Doctor one' will thus just about have had time to put all the clues in place before loading up the next iteration. The dial/castle/Veil is unaware that the state of things upon the loading of 'Doctor two' is not the default, and will take that as a new baseline, leading into the repeating sequence that we saw. More likely is that it took a few iterations, each positioning small clues into place, before the cycle as we know it began.
Potential issues:
* The word 'bird'. Either that shouldn't need rewriting each time or it should already have been erased before the Doctor sees it.
* The dry clothes. Though it's entirely plausible that 'Doctor one' mentally simulated the results of future iterations and left his own clothes there, or that the first Doctor to go for a swim left them there to dry, foreseeing that that manoeuvre would be repeated