There's a technical difference, politically: a realm is a territory with a monarch who is not called a king or queen.  For example, Luxembourg (or The Grand Duchy Of Luxembourg) is ruled by a Grand Duke, and so is referred to as a realm rather than a kingdom.  So, "realm" can be used to describe countries/territories which are "like a kingdom but don't have a king".

EDIT: Somewhat confusingly, given the above definition, "realm" can also be used to describe a kingdom, ignoring the above technical distinction.  Thus a resident of the United Kingdom could talk about "The defence of the realm", meaning the kingdom.  

"Realm" can also be used interchangeably with "area" when talking about **knowledge** - for example, you might say *"This is getting into the realm of mathematics, so I'll leave it to my more technical colleagues"*.  You'd never talk about "The kingdom of mathematics" in this way (because, again, there's no king).