Whatever they're programmed to do, honestly. Don't get me wrong, I like AI in fiction, and sci-fi only benefits from quirky robot companions (see Star Wars, like you said). But if you want to realistically discuss AI, there's a few rules which generally govern robot / AI behavior.
Robots are logical machines
And that's really the key point here. Robots cannot 'break' their programming. They can give the illusion of broken programming if the programming is sufficiently clever, but robots programmed to perform a task will perform it. Thus robots can only take over the world if they are programmed to do so, just note that our definition of 'programmed to do so' may be shortsighted. Take Skynet, for instance. The rogue AI from Terminator was programmed to defend itself, which resulted in Skynet determining everything that wasn't it was a threat. That's not Skynet breaking programming, that's a priority error in it's programming. Hence why Asimov created the Three Laws, but that's on a tangent on how to stop AI from killing us if we tell them to make peanut butter sandwiches.
Robots do have free will, or the ability to make a choice
I really have no interest in debating whether or not humans have free will, or the ability to make choices, but robots definitely don't. There's never a circumstance were, when presented with two options, a robot will ever actually be able to pick both of them. Choice, as far as robots are concerned, is an illusion created by the time it takes to process the variables. So, for instance, if I tell a robot to make a peanut butter sandwich, it doesn't have a choice not to make it (assuming it follows Asimov's Three Laws), or what bread to use, or how thick to spread the peanut butter.
Randomly programmed Robots are boring
So, when I said robots can't choose, that's not to say you can't rig up a system to let them randomly choose to do things, such as deciding to replace my peanut butter sandwich with a jelly one by flipping a coin. That is, of course, possible. But then what you actually have is a robot enforcing chaos, which is boring from a narrative perspective, and not what you're looking for. Also, a robot programmed as such will never defeat it's organic meatbag masters, such as ourselves.
Robots are sterile and uncreative
Lastly, and sadly, to enforce all the points I made earlier, robots lack the ability to create things. A human has inspiration, a robot can only be programmed to mock it. That's not to say we can't have a deep learning algorithm go through Impressionist art and come out with some pretty good paintings, that is to say that without a base and a human to program it, robots would never be able to come up with Impressionist art in the first place. Or, for a more mundane example, figure out that not only can peanut butter sandwiches be made, and jelly sandwiches be made, but peanut butter and jelly sandwiches can be made. So any robot society is pretty much going to be on repeat. Which brings me to my last point:
Robots know what they've been programmed to do
The concept of 'living for a purpose' is a remarkably human one, in the sense that only humans have displayed it. Unless you went out of your way to program a set of robots into overthrowing the world and than angst about it, the robots would be fine, because they would then focus on whatever cause forced them to overthrow the world to begin with. Which, if you've been paying attention to the theme here, is probably making peanut butter and jelly sandwiches. Less humans means more room for growing ingredients and no one snacking on them all the time.