It is "irrational" for a "greedy" slaveowner to kill their slave, a significant monetary investment sometimes, and yet it happened all the time, because capital owners are not rational.
A significant fraction of aviation fatalities can be traced directly back to those "greedy capitalist villains" actually completely cutting corners to save a penny and losing million dollar aircraft.
Business owners are not rational actors, they are gamblers.
For example, you say lawsuits are costly. To a company, that's meaningless. The only question is, is the cost of a lawsuit greater than the money saved cutting corners? If not, it's better to kill people and deal with the lawsuits: [1].
Moreover, companies are still run by people, and people have biases. Most notable of which is the short-term thinking bias that results in companies irrationally optimizing for short-term gains, compromising long-term ones. And what fits perfectly into that trap? Yep, safety. Do you know how much money you could save by delaying maintenance? Lots, lots of money to be had right now vs a nebulous concept of potentially higher chance of an accident at some uncertain point in the future. The monkey with its primitive brain chooses the immediate reward every time.
You probably meant public companies because otherwise this sentence and rest of your comment do not reflect reality.
According to [0] (2019), 90% of (6.1m) businesses have < 10 employees. Lawsuits are a very big deal to these enterprises. They are not out to kill people for marginal profits.