Big profits never fund new research. What justifies new research is a near-term often fairly low risk market opportunity and a mindset to invest in it. Other stuff is out of scope.
There is also a happy medium in terms of profit and competition. A business that is fat and happy will have difficulty doing new things (nothing looks good), and a business just surviving may not have the money and people to invest and the focus is likely on cost cutting and milking the business. On the other hand, there is in an in-between zone, either a company that is struggling to make a profit but has a lot of potential like just getting going or in rapid growth, or one that has been highly profitable but now is seeing a lot more competition and starts to realize that they need to do something. At least my experience from being in R&D (not pharma) for 30 years.