Nobles and their titles/roles are very important historically, as well as being quite useful for a fantasy writer. Of course, you don't have to borrow titles from history but the general feudal system is still pretty handy as a template if you're working in a post-ancient, pre-industrial age.
Rundown of noble ranks:
The baronet and knight are not nobles, but they are a cut above the yeomanry or peasants (a yeoman is a sort of high status peasant, so you might have a Yeoman Master of the Hounds, for example).
So, how did these roles come about and what differences, if any, are there between them?
Starting at the top, the King is an ancient position that goes back as far as mankind does. Top dog, although in a feudal (or Macedonian/Spartan, even) system they don't have absolute despotic power because the nobility have a certain level of autonomy and independence. The position is usually considered hereditary, but that need not be the case. The Golden Age Roman Emperors (kings in all but name) were appointed by their non-paternal predecessors, there was a debate after Alexander's death as to who would become king and, of course, there's the potential for revolution and revolt.
Duke and Count (there's a reason the latter's not on the list, below) both evolved during the latter Roman (and Byzantine) period as powerful military positions. The old system of proconsuls fell by the wayside and new, appointed nobility replaced it, just as the consuls and emperors were replaced by the all-powerful Byzantine basileus (king, though Byzantine emperors are still what they're usually called). Dukes are very powerful, and are not infrequently princes or even an additional title of the King.
In Britain, the Count was replaced by the Earl (an earl's wife is a countess) because of our unique and Vikingy history. Those who have enjoyed Skyrim will know that rulers of holds are called Jarls, and it is from that genuine Scandinavian word that the title Earl is derived.
A Marquis (also spelt Marquess) is below a Duke and above an Earl/Count. The principle difference to the latter is that a Marquis' territory is called a March, and is often in an area that is prone to invasion and in need for a strong and capable man who can handle military difficulties.
Viscount is simply a lower form of Count, and can also be used as a courtesy title for the heir to an Earl or Count (as happened in Bane of Souls with Vicomte Henri).
Baron is the lowest form of nobility, and was introduced to England by William the Bastard to distinguish those who had proven loyal (it's little remarked upon but the war continued after 1066 with Edgar the Aetheling actually becoming the next King of England before being crushed by William).