The math that explains why that is Omohundro calls the formula for optimal rational decision making. It speaks to the way that any rational being will make decisions in order to maximize rewards and lowest possible cost. It looks like this:

In the above model, A is an action and S is a stimulus that results from that action. In the case of utility function, action and stimulus form a sort of feedback loop. Actions that produce stimuli consistent with fulfilling the program’s primary goal will result in more of that sort of behavior. That will include gaining more resources to do it.
For a sufficiently complex or empowered system, that decision-making would include not allowing itself to be turned off, take, for example, a robot with the primary goal of playing chess.
“When roboticists are asked by nervous onlookers about safety, a common answer is ‘We can always unplug it!’
But imagine this outcome from the chess robot’s point of view,” writes Omohundro. “A future in which it is unplugged is a future in which it cannot play or win any games of chess. This has very low utility and so expected utility maximisation will cause the creation of the instrumental subgoal of preventing itself from being unplugged. If the system believes the roboticist will persist in trying to unplug it, it will be motivated to develop the subgoal of permanently stopping the roboticist,” he writes.
In other words, the more logical the robot, the more likely it is to fight you to the death.
via If the Robots Kill Us, It’s Because It’s Their Job – Patrick Tucker – The Atlantic.