“Why do riddles exist in RPGs?”
The obvious answer is “Because Tolkien did it”. Which is the answer to almost every question about conventions in fantasy. (If not this, then “Gygax did it”.)
But I think they are a terrible idea to include in a roleplaying game. Tolkien could use them in his novel because he knew the answer and the reader didn’t have to figure it out for the story to continue. And that’s one of the biggest mistakes many GMs and most writers of published adventures are making all the time: They approach creating adventures like writing a novel and then having the players act out the parts of the characters. But unlike actors, they don’t know the script. Story is certainly a very important element in most roleplaying games, but it works completely different from story in a novel or a movie. Story is what is happening now, not what somewhat has prepared to happen in the future. When you have the characters in the adventure face a riddle, there is a good chance that the players won’t figure out the answer at all. Then what? Or even if they do, it might take them a very long time and can very soon become the opposite of fun.
And what justification is there within the world of the campaign for the riddle being asked in the first place? The sphinx in the desert was asking riddles of travelers or it would kill and eat them. That was not a test of cunning or a password to be granted passage, but simply some additional torture before the poor traveler would be murdered. There was no point to it other than causing suffering. The secret gate of Moria did work really well with a riddle lock. But it worked not because the riddle was challenging, but because there wasn’t any indication that it was a riddle at all. Frodos stroke of genius was not solving the riddle, but recognizing that it was a riddle to begin with. However, that trick works only once and Tolkien already did it.
Other than this one case, riddle locks don’t make sense. Why would anyone secure an important place with a lock that random passer-bys can open with a few minuts of thinking? If it is to make any sense at all, then the answer would have to be something that is only known to people who have been initiated, but which an outsider can not possibly know. Which is very difficult to do in an RPG. Players only remember details about the setting if they know that this detail is probably going to be important later the moment they first hear about it. If a character should know something because of his background, but the player isn’t aware of it, you can’t use it for a riddle either. The only thing you could do in that case is to make a skill check or something like that to see if the character knows or remembers it and then telling the answer to the player. Which would be completely boring.
So my advice to anyone creating adventures: Don’t use riddles. They don’t make sense and are not as fun as you probably think they will be. (Because you already know the answer.)