While seeing the series Black sails, there's an episode where two guys face each other in a pistol duel. While preparing the weapons, it is clearly seen that the assistants put a piece of cloth wrapping the bullets. Why is it done?
Not sure about wrapping a bullet entirely, but muzzleloading firearms do generally require a patch of some kind (typically some sort of cloth or paper) between the ball and the powder. This is because the ball is made to be a slightly smaller diameter than the barrel, so it doesn't get stuck in the barrel while loading. If the gun was fired without a patch, the gases could escape around the ball, greatly reducing the velocity imparted to it. The patch provides a seal to keep the expanding gases trapped behind the ball, so the only way they can escape is by pushing it outwards.
To elaborate on Patrick N's answer, the cloth is called "wadding."