As stated multiple times already, this is the Stormwind Fallacy, a disproven myth that has teeth because it "feels truthy". That part isn't up for discussion, that's already be long discredited.
Yeah what gets me about this is, people repeating it, it's like, really, you believe that? You've playing D&D for this long, and you believe that? Like honestly?
Because I feel it's this thing people say that's completely unreflective, that they seriously haven't thought about. I could have told you it was false after playing AD&D for about 2 years.
There's just really no correlation whatsoever. The ex-munchkin powergamer in my group is a pretty strong RPer and very keen to RP, often coming up with elaborate lines of RP, too, and often coming with much more in-depth backstories for his PCs than other players, ones which often tie in usefully to the world. He'll often have the most optimized melee combatant in the party, but he's also the most likely to have actually detailed friends/relatives etc. in the setting, and will be great at taking onboard setting facts and using them and so on.
And I've certainly seen the reverse, too.
In fact, if I think hard, I'd say if there's any correlation at all, it's between at least
some attempted optimization and being more into RPing the character. Not always competent optimization, but people who care
tend to try. Even that's not always true though. I have one player who selects whatever they think sounds cool/fun with no real regard for optimization in D&D (not all RPGs, bizarrely, he was really thinking hard over what to pick for his Medium Advance in Spire!), and also does a good job RP'ing.
I find it incredibly hard to believe that anyone who has played 5 or 10 or 15 or more years has never seen a PC who was optimized and RP'd well, or vice-versa.