How did Cleopatra become queen of Egypt?

Originally Cleopatra was supposed to be a co-ruler with her brother, as stated in her father's will. A power struggle broke out and Cleopatra was dethroned. Julius Caesar restored her to the throne in 47 BC.