Let's say for example in England. Could the king just go and pick random girl from a village or town and rape her? Where there any consequences?
What about the Queen? Could the King decide when he wanted to sleep with his wife and she had no word in the matter? I've found no information on either of these subjects when i've tried to look for it. If it varied based on time/country i would appreciate if you told about different times/countries.
Kings and nobility were often restricted by very different sets of laws and rules, so it might be best to specify when and where you are asking. Medieval Kings actually probably had less freedom under the law than later Renaissance era Kings who ruled as absolute monarchs.
With regard to the second part of the question, the King of England was, legally speaking, free to rape his wife since English common law had no restrictions on spousal rape. Spousal rape was not considered rape until the 1970's in many places. This was probably true for most of the world at the time.
Blackstone's commentaries on English Common Law notes that even as early as the Kingship of Athelstan in the 900's, rape was punished with death, and later castration and loss of eyes by the time of King Henry the Third in the 1200s. The punishment for rape vacillated between death and severe punishment for most of the Medieval era. Whether or not this had a realistic chance of being applied to a medieval King is beyond my knowledge.
There are plenty of other ways they could have raped women without punishment. For example, women were often raped during the looting or sacking of cities, for example, and it is possible a King or other noble person engaged in this form of violation. This was just considered part of warfare, if unfortunate.
edit: I put part of this in quotes because I misinterpreted the question
What you're talking about is called droit du seigneur and it's an urban legend perpetrated in the 18th century by French republicans. When the French peasants recorded their grievances against local lords, they were encouraged to say anything they could think of but nobody came up with as weird a custom as this.
Source: http://gallica.bnf.fr/ark:/12148/bpt6k258808/f378.item.r=
In the 18th century version of this urban legend, as recorded in Diderot's Encyclopédie, the right extended not only to lords but also to bishops. This obviously reflected Diderot's own anti-clericalism, and shows how the legend can be twisted to fit any given group.
I don't know why you mention the queen, but marital rape was not law anywhere in the world until the 1960s.