Talk of doing society good is by now a standard component of American companies’ messaging.

Whether they meet that stated goal is another matter, but still, the impetus for it all is still a bit mysterious: Why have multi-billion-dollar firms invested so heavily on corporate social responsibility, or CSR, programs in the last few decades? Are firms engaging in socially conscious behavior for honest reasons, or simply to direct attention away from some of their more harmful behaviors?

A new paper published in the Journal of Marketing investigates the motivations behind companies’ implementation of CSR programs. It also looks at bad firm behavior and firm performance to figure out what drives companies to act conscientiously and what benefits they reap from doing so. The paper examines 4,500 firms over a 19-year span and compares implementation of CSR programs with instances of social irresponsibility.

The study’s authors—Charles Kang, Frank Germann, & Rajdeep Grewal—identified four potential rationales for instituting CSR programs. The first is what’s called the slack resources theory, which assumes that when a firm is doing well, it has plenty of extra money to play around with. So firms will use some of that money to create programs tailored toward social good. According to this theory, firms start or end such programs at will, basically depending on whether or not they’re in prosperous times. Another theory suggests that companies view CSR programs as good management practice, since firms that focus on social good can reap financial rewards—such as increases in sales, more loyal customers, good press, or the ability to attract more high-quality employees—because of their good reputation.

And then there are two theories that suggest CSR programs are created when companies want to avoid, or counterbalance, scrutiny of their behavior. The first is the penance theory: Firms engage in CSR to help make amends for bad things they’re responsible for (things like oil spills, where the amount a company pays in restitution is likely still less than the actual financial toll of their disasters). Another is the insurance theory, where firms put together CSR programs to help mitigate any damage to their brand that could occur from future bad behavior: Build a good reputation now, so that customers and shareholders don’t defect later when a firm does something bad.

Among these four theories, the researchers’ analysis suggested that most CSR programs are implemented as a matter of good management practice, or to atone for past bad behavior. The researchers found that for many companies, investing in CSR because they think it’s the right thing to do or a good move for the business overall pays off by improving the overall financial performance of the company. When looking at market-based measures of performance, firms that made decisions to incorporate these programs into their business strategies saw a boost. That gives some credence to the theory that firms can in fact “do well by doing good.”

There’s a caveat, though: The study found that the implementation of CSR programs often correlates with instances of irresponsibility, meaning that companies that aren’t already investing in CSR programs are likely to do so soon after their discovery or public revelation of corporate wrongdoing. But in those instances, programs aimed at social good usually don’t offset the financial damage done by a bad action, since they can be seen as inauthentic, or as insufficient compensation for deeper wrongs.

The researchers are careful to note that their findings are by no means a definitive explanation for firms’ motivation or the rise of corporate responsibility programs. But their research suggests that consumers are more discerning than they might seem, rewarding the companies whose investment in social good is more than a public-relations crusade.