It is generally held that, immediately prior to Islam, there was a lunar calendar in use in Mecca and Medina with twelve months and seven days per week; however, extra days were added each year so that it would match the solar calendar instead of being shorter than it (so the months would not move around the solar year). The Prophet (S) made the lunar calendar strictly lunar (without any extra days).
Additionally, years were referred to by events (such as "aam al-fil", or the Year of the Elephant), and this continued during the lifetime of the Prophet (S).
It generally held that, during the caliphate of 'Umar, at the suggestion of Imam 'Ali (A), the decision was made to count the years in the Islamic calendar beginning with the hijrah, instead of referring to the years by important events that happened to them, to make things easier for the expanding bureaucracy of the Arab-Muslim Empire, and thus it became the hijri calendar as we know it today. Some people hold that the Prophet (S) himself mandated the first year of the Islamic calendar be the year of migration, but this view is not very common.
Anyway, calendars can be quite complicated - people today often take them for granted because we have digital devices and communication by which we can all agree on the date and time, but for much of human history, it was a big challenge and responsibility to keep up with the calendar!