The purpose of flogging in ancient times was to inflict punishment and deter others from committing the same offense. It was a common form of punishment for a variety of crimes, including disobedience, theft, and blasphemy.