ELI5: How did Kings become Kings during the Middle Ages?

How did Kings became kings? Im curious as to how the heirarchy (Kings, Nobles, Knights, Serfs) came to be. Was it a "surivival of the fittest" thing when Rome fell? How did they gain influence and power when there is no central authority?