In Star Wars: Episode VI - Return of the Jedi (1983) in a scene we can see Luke trying to attack the Emperor with his lightsaber. But Darth Vader stops him.
Why does Vader stop Luke when he tries to kill the Emperor?
Vader wanted Luke to have loyality with him, not Palpatine.
Darth Vader: Luke. You can destroy the Emperor. He has foreseen this. It is your destiny. Join me, and together we can rule the galaxy as father and son. Come with me. It is the only way.
But for this, he has to turn Luke to the dark side. He had to show the power of hate and anger, that will eventually lead him to the dark side, but when he tried to strike Palpatine, he did not have anger and hate flowing through his veins. At that time, he could have killed the Emperor, but Vader needed him to accomplish this.
Emperor: Patience, my friend. In time he will seek you out. And when he does, you must bring him before me. He has grown strong. Only together can we turn him to the dark side of the Force.
As we can see, only Vader and Emperor Palpatine together could've turn Luke to the dark side.
We can see Vader later provoking Luke in order to do that.
This Sci-Fi answer to similar question also shares more details.
To reply the comment that asked that he wasn't going to kill Palpatine and rule the galaxy, here is the conversation between Padme and Anakin (Vader) in Revenge of the Sith,
Anakin: I have brought peace to the Republic. I am more powerful than the Chancellor. I- I can overthrow him. And together, you and I can rule the galaxy, and make things the way we want them to be.
Simple. He (Vader) knows how strong the Emperor is. If Luke tried to stop him (the emperor) Luke would have died. So sacrificed his own life to save Luke