It
is an investment from a
managerial accounting perspective (how the business really works), no matter what it's called by financial/tax accounting (how the business formally reports its status). Expenses, such as taxes or the electric bill, pay for things you use up. You can't keep them, keep using them, or resell them. But R&D is an attempt by management to produce IP assets, some of which will be used for years and can even be embodied in patents and sold, like land or machinery.
Financial accountants can't deal with the unpredictable outcome and the fact that even success is hard to quantify. They can't put the million-dollar payment in one column and the specific million-dollar asset that was purchased in the matching column, which is required to make the books balance, so they call it an expense.
It's not a case of something that is really an expense but is mistaken for an investment by "laymen". On the contrary, it is really an investment in IP asset creation by management that financial accountants have to treat as an expense, like paying taxes, due to limitations in the accounting "technology" they are required to use.