The Pillory Guard is a random event character that will come and threaten to lock up the player. If the player agrees to come along quietly, they will be taken to the Pillory random event. However, the player can ignore him if they do not wish to participate.
Before the 2014 update that made random events optional, the Pillory Guard would appear to players only while they were thieving. He would automatically teleport them to the Pillory, where they were required to solve the puzzle in order to continue playing.