There's nothing particularly magical about emotion - it's just a low level computation by our subconscious that we don't have conscious access to. Happiness, anger, fear, etc are all responses to the environment we evolved because they produce (or at least, did at one time) useful actions. It's the mechanism the brain used to make predictions based on data before it developed a consciousness.
An AI would make predictions based on data just like a human would, but the mechanism it used to do it would certainly be different.