Slavery started very early in human history, with evidence tracing it back to as early as 6800 B.C. in Mesopotamia, one of the world's first city-states. Slavery began with the capture of war prisoners who were forced to work, and as ancient civilizations grew, slavery became an economic institution to provide cheap labor for construction, agriculture, and trade. It existed in many early civilizations including Mesopotamia, Egypt, Greece, and Rome.
So, slavery as an institution started thousands of years ago, well before recorded history, and was deeply tied to war, conquest, and economic needs in ancient societies.