The medieval times were a truly fascinating period, and the Byzantine Empire is probably the most interesting in the bunch, partly because of the relative continuity and wealth of primary historical sources, both by the Romans (Byzantines) themselves and the people who interacted with them, so we know about them in greater detail than most. It's important to understand that the prophecies were taken very seriously and often had a profound impact on the sentiments and actions of not just the masses, but the ruling class and emperors themselves as well, and often recorded in the history books for our benefit.
I don't know how this particular prophecy came to be, but it predicted that the order of the first letters of the names of the rulers of the Komnenian dynasty would follow the pattern A - I - M - A. Again, as far as I know, it came up sometime during the reign of Manuel I Komnenos (1143-1180), who ruled after his grandfather Alexios I (1081-1118, I believe) and his father John (Ioannes, 1118-1143). The prophecy was so revered by Manuel that he actually meant to have Bella assume the Roman throne not as Bella, but under the name Alexios II, in order to fulfill the prophecy. The plans became irrelevant with the birth of the heir who, again, was given the name that "appeases" the prophecy - Alexios.
It is also interesting that the usurper Andronikos I Komnenos who elbowed his way to the crown a few years after the death of Manuel, lived in fear of his cousins with the names starting with "I", believing that the prophecy is going for another turn, so to speak. He was, however, deposed by Isaac Angelos, who started the new, though short-lived, dynasty.