The usage of epithets and sobroquets between royalty became a thing especually in the Middle Ages, due to, mostly, the need to have a way of diferentiating between same-named monarchs.
Because regnal numbers wouldn't start to be used until the late Middle Ages, the way of knowing who was the Charles, Louis, Henry or Alfonso that someone was talking about was via epithets, which usually referred to something characteristic of the king in question (there is, for example, sixteen Louis in French history, but only one Louis the Stammerer; and thirteen Alfonso in Spanish one, but only one Alfonso the Chaste).
However, even when regnal numbers became a thing, epithets were still used: in Spain, for instance, Felipe IV (r. 1621-1665) is known as "el Rey Planeta", which basically means 'the Great', his son, Carlos II, as "el Hechizado", or 'the Bewitched', and a much later king, Alfonso XIII, who reigned from his very birth in 1886 to 1931, when he was forced to exile and the Republic was proclaimed, is known as 'the African'.
It is also worth going much further in time than the Middle Ages if we are to find, on the same reasoning of identifying kings with the same name, an even more excesive usage of epithets. This is, the Hellenistic Age.
When Alexander died and his empire was carved up between his generals, the decades-long strife for supremacy ended with the consilidation of three kingdoms, Macedonia, led by the Antigonid dynasty, Egypt, ruled by the Ptolemies, of which Cleopatra was the last member, and the Seleucid kindgom, which extended from the Aegean coasts to modern Afghanistan.
These dynasties, especially the Ptolemies and the Seleucids, used a fixed number of dynastical names, that is, Ptolemy for the first ones, and Seleucus and Antiochus for the second ones. The result is that, when some generations have passed, 'king Ptolemy son of king Ptolemy' or 'king Seleucus son of king Antiochus' could literally mean six or seven different rulers.
They knew it, and hellenistic monarchs made heavy usage of epithets to diffefentiate themselves from their predecessors and eventual successors. And this is an interesting difference: while in the Middle Ages epithets and sobriquets were mostly used posthumously or as 'nicknames', hellenistic rulers used them as part of their very name.
That way, historians would not write about king Seleucus, son of king Antiochus, but about 'king Seleucus Kallinikos (who is Seleucus II in modern naming convention), son of king Antiochus Theos' (Antiochus II). This was even used in coinage, which proves that, unlike medieval rulers (Louis the German or Aethelred the Unready would have never used such nicknames officially), royal epithets for hellenistic monarchs were not only officially used, but actually stablished from the institution itself.