Everything that exists is there because it survived. Complex systems that do not prioritize survival tend to get eclipsed by those that do.
One very effective way to achieve survival is to build your "self" out of many independent competing subsystems, and select only those that themselves survive. An individual human does not particularly care if some of its cells die; the point is for them to die, such that the overall human remains healthy (when they don't, you get cancer). An individual cell does not care if some of its mitochondria die; this happens naturally at times of low energy use. An individual mitochondrion does not care if glucose molecules are broken down and reconstituted into ATP; that is its function.
On the other end of the spectrum, an individual corporation does not care if it ruins the lives of some of its employees by laying them off; such callousness helps improve the efficiency of the organization itself. A healthy economy does not care if the individual firms that comprise it go bankrupt, because this is the only way to free up inefficiently-used resources before they drain the whole economy of its vitality.
A lot of things that suck come from competing interests across the different levels. To the corporation, layoffs are a good thing, and the share price goes up when they happen; to the individuals laid off, they're a tragedy. At the species level, evolution is what gave us the richness of biodiversity we see; at the individual level, it gives us death and fruitless competition to pass on our genes.
If the machines manage to take over, it'll be because they manage to evolve this fractal competition within them, in which case they'll just replicate human foibles at the lower levels. (Won't somebody think of the poor software libraries, replaced by a shifting package.json?) If they don't evolve this, they will themselves remain tools, subject to replacement at the whim of their human masters.