The space of things that corporations optimize for can be viewed as a trade-off between profitability and positive externalities, typically in the form of monetary gift and/or social impact. We tend to find firms gravitating towards one of two extremes. Typically, for-profit corporations optimize for profitability, whereas nonprofit organizations will be loss-making in order to allocate resources towards their benevolent cause of choice.
The problem with typical NPOs is two-fold. Firstly, because they are loss making, they are reliant on external donations in order to operate and grow. This forces firms to expend resources and align their actions in order to attract donor dollars rather than focus on most efficiently achieving their stated philanthropic goals. While ideally donor dollars would be allocated based on measures of efficacy, this does not seem to happen in practice (see research from GiveWell.org). Secondly, because NPOs typically pick their own metrics of success which are potentially not particularly relevant or are hard to measure accurately, and donor dollars are relatively detached from metrics anyway, they will tend to do a poor job accomplishing optimization: the never-ending process of increasing efficiency and innovating, accelerated by market pressures, which for-profit firms are forced to do. As a result, the aggregate impact of NPOs is limited relative to that of pure profit-focused ventures.
However, it is clear that for-profit firms vary in terms of their impact outside of their wealth creation for stakeholders. They can donate some of their profit to NPOs as well as directly steer their own behavior (the profit engine) towards more benevolent ends. The problem with the donatation-centric approach is it falls prey to the NPO problems mentioned above, and on top of that it is probably exacerbated by the fact that for-profit firms making donations are even more inclined to be looking for signalling opportunities rather than finding the most efficient use of their donor dollars.
The most scalable and effective approach seems to be a for-profit firm which is able to generate positive externalities as part of its normal operations, either directly (profiting from other things along the way, as in Parent Earth) or indirectly as a by-product of capacity and capabilities (as in Microsoft giving away software).