In British royalty what is the difference between duke and Earl. Some titles use duke (for example duke of york) and some use Earl (Earl of Wessex). Is this due to different cultures in early medieval Britain such as the Saxons and vikings or are they different ranks?
Preliminary note: "royal" is "of or relating to a monarch", and sometimes applying to their family.
As /u/Panceltic pointed out, there are certain ranks in England: duke / duchess, marquis / marchioness, earl / countess, viscount / viscountess, baron / baroness. (I'm not as familiar with Scotland, so I'll not consider their lords and ladies of Parliament.) These are the ranks now called "noble", though that term used to be used more broadly.
The titles had various origins and evolved over time. Barons originally could be created by writ of summons to Parliament. All of these could be created explicitly by charter or later by letters patent, and in such a case, the document stated the rank and title (duke of Cornwall, say) and how the title was inherited (the term for that is "the remainder"). The rank and title were then fixed. For example, there were a bunch of guys surnamed Percy who were called earls of Northumberland but not duke of Northumberland. Yes, later ones were called duke of Northumberland, but that's because in 1766 the crown gave Hugh Percy, existing earl of Northumberland, the higher and separate title of duke of Northumberland, which has been inherited together with the title earl of Northumberland (and Earl Percy, Earl of Beverley, Baron Warkworth, et cetera).
The etymologies of the terms was a bit random. For example, "earl" was derived from Norse "jarl", but an earl's wife (or female earl in her own right) is called a countess, and "earl" was early on equated with French "count" and referred to in Latin as "comes". But that doesn't affect the later treatments of the different ranks.