Since you asked this, it will be quite an instructive exercise to answer it. There is a game called Thief. It is a semi open-world game. In the game, and it is a world that is really well designed and exploring it is pure joy, especially with the freedom and abilities the game gives you to interact with the environment. But it is not an RPG. This tells us that exploration is not a core mechanic of RPGs.
Then you can imagine playing another game called...Thief, where you have a fantastic storyline brought to life through seemingly unconnected events and dialogues as well as cutscenes. The setting and the storytelling is a masterpiece in gaming. But, Thief is not an RPG. Thus, neither storytelling or a setting are a core element of an RPG. Neither are well-designed characters. Interesting. We, through the process of elimination, are getting somewhere.
Then you play a game called Thief. You seem to have heard the name before. But never mind. It has a fantastic level design that allows for a variety of approaches. It has amazing reactivity where the enemy can hear you run around and look for you. Hmm. Still not an RPG. Looks like environmental reactivity does not an RPG make.
Then you play a game called Mask of the Betrayer. It has a lot of choice and consequences which actually change outcomes within the game so that they are not cosmetic only. Hmm. This seems like an RPG? Does it not? Maybe C&C is a part of RPGs. Let's add that to a tentative list.
You also come across a game called Expeditions conquistador, where you have to choose the defining attributes of the main character. And hey, its quite fun to try out different combinations! There is a variety of builds which alter the experience of the game and allow for different outcomes within the game! What fun! Maybe, character design is a defining element of RPGs too!
I think with these clues you come to a conclusion. Maybe games where you have a measure of control over how the character interacts with the world *and* (the logical kind) that interaction can change the outcome of the story within the game in some non-cosmetic manner, then the game is an RPG.
Now since these two aspects define an RPG, those are the once when done well, make me enjoy an RPG. Good C&C and deep character design.
Examples of great RPGs:
Age of Decadence
Deus Ex
Mask of Betrayer
Planescape Torment
Expeditions Conquistador
Jagged Alliance
XCOM
Arcanum
Blackguards