Why did surnames emerge
First names have likely existed since possibly soon after humans evolved into their modern forms. However, the origin and development of surnames (or last names) is far less known and is likely a more recent phenomenon. People were often designated by their larger kinship groups, often through a male line but sometimes female, as part of their identification in more ancient periods. Distinguishing by a specific surname for a person though is still not universal throughout the world, although it is now very common.
Origin of Surnames
Surnames, of sorts, are known from ancient periods. However, these surnames often had to do with clan names or names of places used as a way to distinguish a person. For instance, in ancient Greece, it would be common to refer to a person from an ancient city. Another way people were distinguished, which is still used such as in tribal groups in the Middle East today, is to refer to the name of the father for the son or daughter as the person's second name. Someone would be referred to as the son or daughter of someone, where the father's first name would then be used as something akin to a surname. In the Roman Empire, family names were sometimes used, but often this had links to clans or if other systems were used family names would often drop or not be carried from generation to generation.
Early surnames were generally not fixed and this meant that after one or two generations, it was common to lose links with someone's more distant past. The first recorded surname where that surname appears to be fixed appears in the 10th century in Ireland, where the surname Ó Cleirigh could be the oldest continuous surname. However, centuries later surnames were still uncommon in most of Europe and if surnames were used it was usually in reference to an occupation or sometimes in reference to someone's father. In effect, these surnames did not continue beyond a few generations. Surnames may have begun to become more established in the West during and after the Norman conquest. At around the 11th century, the Norman nobility began adopting surnames the denoted location of origin or land in which they held. This allowed them to make claims to land and it was common to use the French 'de' (of) in connotation to a place or land. This then became a way the noble classes could distinguish themselves from others and it also allowed them to use this second name as a way to pass that name to their kin so that land could be inherited. It effectively became a status symbol to have a fixed surname so that there was no ambiguity of the person's status. This was similar to how French feudal land owners also used designations such as 'de' to identify their land ownership.