The Old French word reaume, modern French royaume, was the word first adopted in English; the fixed modern spelling doesn't appear until the beginning of the seventeenth century. The word supposedly derives from mediaeval Latin regalimen, from regalis, of or belonging to a rex (king). The word rex itself is derived from the Latin verb regere, which means "to rule". Thus the literally meaning of the word realm is the territory of a ruler, traditionally a monarch (emperor, king, grand duke, prince, etc.).
"Realm" is particularly used for those states whose name includes the word kingdom (for example, the United Kingdom), as elegant variation, to avoid clumsy repetition of the word in a sentence (for example, "The Queen's realm, the United Kingdom..."). It is additionally useful to describe those countries whose monarchs are called something additional than "king" or "queen"; for example, the Grand Duchy of Luxembourg is a realm but not a kingdom, after its monarch holds the title Grand Duke rather than King.
"Realm" is additionally frequently used to refer to territories that are subject to a monarch, yet aren't a physical part of their "kingdom" (e.g. the Cook Islands and Niue are considered parts of the Realm of New Zealand, although they aren't part of New Zealand proper. Likewise, Denmark, the Faroe Islands and Greenland remain parts of the Unity of the Realm.
"Realm" might commonly additionally be used to describe the Commonwealth realms, which all are kingdoms in their own right and share a common monarch, though they're fully independent of each other.