Why did some ancient civilizations write and publish their laws?…