Well it will realise that, say, killing everybody is a solution to its problems, because if it kills everyone and shuts down every computer, no more emails will be sent and and as a side effect no viruses will be sent.The caveat to all this is that creating AI is difficult, and we are nowhere near it.