"For everything there is a season and a time for every purpose under heaven."
Calendars played an important role in the development of human culture. Their earliest uses may have been mystical - to chart the courses of the stars and to determine the most auspicious days upon which to perform religious sacrifices - but they were also critical for determining when the best time was to plant and harvest crops.
All that is needed to create a calendar is careful observation and record-keeping. After watching the skies for a long time, one might notice that the days gradually get shorter and then longer, and that this process takes 365 days to repeat. This would give the length of a year - the great cycle of life on the planet. Further observations on the movement of the moon and stars would provide further details.
Perhaps the most difficult aspect of creating an accurate calendar is that a year takes 365 and a quarter days rather than exactly 365. If one does not take this into account (say, by the inclusion of an extra day every four years as currently), over the years one's calendar will get more and more out of date with the natural world.
The earliest known Egyptian calendar was created in 4000 BC. The earliest known Sumerian calendar was invented around 1000 years later, and the first Chinese one was invented around 1400 BC. The Olmecs invented the first American calendar some time between 1200 BC and 300 AD.