Imagine that you have two companies producing pens, and society currently uses X pens/year. If company A can find a way to automate production, they can sell pens cheaper than B (and/or at a higher profit margin). Because A laid off people, society no longer consumes X pens, but the difference is distributed between both A and B (and other pen companies, and non-pen companies would also see a loss). Assume every company acts in their own best interest.
If company A instead uses their extra money and gives it away to their now unemployed former employees, then society would be back to using X pens/year, and demand is maintained. But that is clearly not in A's best interest, so they do not. Now we have the ability to produce more stuff as a society (not just pens, because the unemployed can be used anywhere). However, all this gets us is people who can no longer afford what they once could.
If company A instead uses their extra money and gives it away to their now unemployed former employees, then society would be back to using X pens/year, and demand is maintained. But that is clearly not in A's best interest, so they do not. Now we have the ability to produce more stuff as a society (not just pens, because the unemployed can be used anywhere). However, all this gets us is people who can no longer afford what they once could.