In Medieval times European kings, nobles, and rulers were usually known by one or more nicknames whenever someone wanted to tell them apart from others of the save name and same realm or from contemporaries in other realms.
The pope started using numbers in the Middle Ages but not soon enough to avoid a number of problems with their numbering.
The Holy Roman Emperors were the first to officially use numbers in the reign of Otto III (died 1002). After a gap the practice was resumed in the reign of the Emperor who called himself Henry III (who is listed in every source you will find as Henry IV, using his number as king of Germany). There is a question whether to count the numbers of Kings of the Romans who were never crowned Emperor, so the Emperor listed as Henry VII could be called Henry VI, Henry VII, or Henry VIII.
Mere kings hardly ever used numbers during the Middle Ages, they usually started in the Renaissance and later. Thus the numbers used for ancient and medieval rulers are almost always assigned by later historians. And sometimes they don't add up.
For example the kingdom of England is sometimes considered to have been officially founded on 12 July 927. Anglo-Saxon king Edward the Elder reigned over Wessex and most of England from 899-924. He can be considered King Edward I of England. If Edward the Elder is not considered a king of England then Saint Edward the Martyr (reigned 975-978) can be considered King Edward I of England and Saint Edward the Confessor (reigned 1042-1066) can be considered King Edward II of England.
Thus when English kings started to use their numbers in official documents King Edward, son of Henry VIII, should have been called Edward VIII (counting from Edward the Martyr) or Edward IX (counting from Edward the Elder) but instead was called Edward VI, counting from Edward Longshanks (reigned 1272-1307).
The kingdom of England united with Scotland to form the Kingdom of Great Britain in 1707. Great Britain united with Ireland to form the United Kingdom of great Britain and Ireland in 1801. In 1801 George III should have changed his number to George I. But monarchs like George IV and William IV continued to use numbers like they were still kings of Great Britain or of England.
The two monarchs of the United Kingdom named Edward should have been numbered Edward I and Edward II since they were the first monarchs of the United Kingdom named Edward. If they were numbered like English kings they should have been numbered Edward IX and Edward X (or possibly Edward X and Edward XI if Edward the Elder was counted). Instead they ere numbered Edward VII and Edward VIII.
Who was king of Sicily before Roger II? Nobody. Count Roger II founded the kingdom of Sicily and historians never bothered to give him a separate number as king of Sicily. Similarly King Frederick II (died 1337) of Sicily was really Frederick II but called himself Frederick the third to honor King Frederick I of Sicily who was always called the Second because he was emperor Frederick II.
One of the oddest quirks in numbering is that King Martin I of Sicily was succeeded in 1409 by his own father, King Martin II of Sicily, who was also king Martin I of Aragon.
As another example King Carlos I of Castile was also King Carlos II of Sicily, King Carlos IV of the other Sicily, Emperor Charles V, and so on.