This thread is posted in the D&D sub-forum but seems to be talking about RPGing more generally.
D&D is in my view a somewhat unpropitious game for thinking about the portrayal of characters via roleplay, because (based on my knowledge of what is published, together with my sense of what play looks like based on encountering others' descriptions of it), D&D play seems to fall into a few main categories:
* Classic, Gygax-ish D&D where the goal of play is to advance your character by earning XP by successful extraction of the loot from the dungeons, lairs, etc the GM has created. In this sort of play there may be alignment rules, and racial preference charts and associated rules (eg hobgoblins prefer to attack elves because of the great hatred they bear them: MM p 53), and of course some or even much of the banter between players may be understood to be occurring between their PCs. But one the whole character does not loom large in this sort of play, because it simply doesn't fit with the goals of play.
* More contemporary, challenge-focused D&D which differs from Gygaxian D&D in that the GM plays a more active role not only in designing the "setting" but also framing the scenes (eg deciding what encounter happens next), typically with a shift in XP rules from XP for loot (which shifts the onus onto the players to decide where they go next) to XP for combat (or near-combat) victory (which sits well with the GM deciding what the next challenge will be). Like Gygax-ish play this sort of D&D still assumes a team of PCs who work together, and it assumes a fairly generic set of motivations (such that it is easy for the GM to find "hooks" for the next encounter). As with Gygax-ish play, more than a very modest amount of character will interfere with the goals of this sort of play.
* Probably sitting on something of a spectrum with the sort of play described in the previous paragraph, there is "story-driven" D&D play: the GM comes up with a basic conception of a mystery or some other sort of plot, and the players run their PCs through it. In 5e, this sort of play lends itself well to milestone XP rather than XP for victories. It makes sense for the PCs to have enough and the right sort of character to generate their entry into the story. But too much or too divergent character risks destabilising the whole set-up. Eg what if the PCs decide that they like the "big bad" and want to help in the nefarious scheme?
A practical upshot of the intersection between these approaches to play, and aspiring to portrayal of characters, is that a lot of D&D advice (I'm thinking especially of 2nd ed AD&D, but also some of the discussion in the early part of the 4e D&D PHB) tends to focus on
characterisation: what does the PC look like, what are their mannerisms and catch-phrases, etc. There is much less focus on what the PC
wants and how they will go about getting it (4e D&D is an exception to this in the latter part of its PHB, where it talks about player-authored Quests).
RPGs that put character front-and-centre also tend to change assumptions about
what the goal of play is - which then feeds into changes in the techniques used to determine what happens next, what challenges are confronted by the PCs, etc.