We’re not talking about situations where slight differences in pharmacokinetics mean that drugs that are supposed to be identical aren’t. Those slip through the system, and it’s bad.
Some economists investigated this question, because that’s what economists do. Before analyzing actual purchase data from actual consumers, they hypothesized that most people who buy name-brand drugs when a generic is available do so because they don’t know any better. For many consumers, that’s true.
They know this because they compared the buying habits of medical professionals (nurses and pharmacists) against the whole population. 70% of the general population bought generic OTC drugs, but 90% of pharmacists and nurses, who are presumably better-informed, did so.
What about everyone else? Some people who know better buy brand-name drugs just because of that brand name. One person who spoke with an NPR reporter claimed that he didn’t want his wife to think he’s cheap.