It is difficult to ascertain a precise beginning point for formal education. Early humans, who were hunters and gatherers taught the skills of hunting, etc. to their young, most likely by example. Later, as complex societies developed with stratified social frameworks, education became more formal. Originally, all education was oral, such as songs, epic poems, etc. The Vedas of ancient India is an example.
The development of writing was a major factor in the development of formal education in a school-like setting. The best guess is that it originated in ancient Mesopotamia in which the sons of the wealthy were taught cuneiform. Cuneiform is a complex writing system not easily learned, and the process itself was not for everyone; only the very rich could afford it. Later, less complex forms of writing developed, and education became more widespread.