The short answer to your question is that you wouldn't. It would be a really (REALLY) bad idea (and dangerous to boot) if it's even possible, which I don't think it is.
Let's start with a bit of simple neuroscience. Over the course of evolutionary history, brains have developed 3 primary functional centres; the cerebellum, the Limbic System, and the Cerebral Cortex.
The Cerebellum (hard wired electrical) is the seat of autonomic functions, like keeping the heart beating, etc. It's also the source of primary instincts, like survival, hunger, procreation, etc. These instincts are designed to drive the animal in question, force them to do certain things to ensure the survival of the animal itself and its species. Trouble is, having hard wired responses don't always lead to the right result, so a new area of the brain evolved, designed to override instincts under certain conditions.
The Limbic (chemical) system, also called the 'Reptilian Brain' is the seat of emotions. In certain contextual situations, it's important for behaviour to be driven in a manner that overrides instinct, like protection of young at personal risk. It also stimulates hormone production, like adrenaline, to encourage best possible action in a fight or flight response moment. This is also a motivating area of the brain, but it too can cause you to make the wrong choices in certain contexts, and doesn't cater for situational (contextual) responses, hence the evolution of the Cerebrum.
The Cerebral Cortex (soft wired electrical) is the 'programmable' part of the human brain and allows for learnings to be developed within a single lifetime, rather than an extended period of evolutionary development. Also known as the mammalian brain, it is the seat of reason and what we consider intellectual learning.
(All this is a simplification, but functionally accurate)
Computers ONLY replicate the cerebral cortex functions, and even then only to a very limited degree.
The point of this is that computers DON'T experience a survival instinct, don't get happy or sad, or angry, and wouldn't understand what those emotions were even if they did. Skynet simply can't happen; at least, even if a computer system could become aware, it doesn't follow that it would act to preserve itself in any way. It simply doesn't have that innate motivation.
Sure; you could program it to prefer survival, but if you really want a machine to start trying to wipe humanity out, you don't need an AI to do that. I could program a drone to fly around, shooting anything that moves, returning to an automated refueling and rearming base whenever it's low on supplies, and that would take little more sophistication than a sophisticated modern video game.
Additionally, because emotions and instincts are NOT programmable, any attempt to simulate them in computer code would only be exactly that; simulations. The computer would not actually experience these emotions, but would emulate that experience, which in turn would only serve to confuse humans interacting with it.
And there's your only real answer; if you want the machine to be some sort of infiltration device, confuse the enemy into thinking that it can be reasoned with, then you introduce emotions so that humans begin to relate to it and anthropomorphise it. But, that robot won't actually feel emotions regardless. In that sense, the introduction of emotional responses would be for human benefit, not robotic.