In part 1 chapter 2 of Gulliver's Travels, Gulliver wakes up in chains on his first morning in the Lilliputian Temple. He stands up and admires the countryside. He relieves himself inside the building, but feels guilty for doing so. Despite chaining him up, the Lilliputians have treated him with great hospitality.
He resolves to make his morning duties outside, away from the temple, so servants can carry away his waste. The emperor arrives at the temple on horseback and speaks, but Gulliver can't understand his strange language. The Emperor leaves, placing Gulliver under the watch of his guards, some of whom attack Gulliver. This violation of the Emperor's will and courtesy is treasonous, and as punishment, these guards are given to Gulliver to do with as he pleases.
He pretends he's going to eat one soldier to scare the men, but he does not hurt them and gently releases them. Indeed, they are scared out of their wits. Gulliver's mercy impresses the Emperor's court.
He agrees to give Gulliver meals, servants, and a tutor to teach him the Lilliputian- language. Gulliver learns quickly and asks to be set free. The emperor is reluctant about this, and he refuses Gulliver's freedom.
Instead, he favors Gulliver and gives him special accommodations. Gulliver cooperates with the emperor's order to search Gulliver for weapons. The emperor does not recognize Gulliver's pistol, so Gulliver demonstrates its function by firing into the air, which terrifies a massive gathering of Lilliputians. Two officers make a detailed inventory of Gulliver's pockets, which Gulliver uses to store his weapons.
which to them are full of strange and amazing artifacts. They allow Gulliver to keep most of his things, but he surrenders a knife, a razor, and the pistol. Gulliver takes pains to describe the full state of his desperation to relieve himself as an explanation for his decision to do so inside his house. The detail of his embarrassment demonstrates Gulliver's desire to appear civilized, both to the reader and to the Lilliputians.
He wants to make a good impression. It's clear the Lilliputians left Gulliver with no no instructions or plans for dealing with his excrement. As satire, this incident highlights the way governments fail to deal with the unintended consequences of decisions. In this case, the decision to keep Gulliver in chains in the temple.
They have to clean up a literal mess because they did not anticipate it. And only after the worst has happened do they form a plan to deal with the problem.