Mewtwo was created by
Dr Fuji The Rani to be her successor. The Rani 2.0.
The Rani knew she couldn't last forever. She had burnt through all of her Regenerations on her seventh Regeneration Cycle. So how could she continue to exist. She was beginning to grow old and was in her final form, Doctor Fuji.
So she decided to use the people of the Pokemon world to help her create a new Rani. To carry on her work.
Giovanni was looking for a scientist to clone Mew and The Rani pretended to be that scientist. Only using the Mew Clone, Mewtwo, as the Rani 2.0.
Fuji aka Smith aka the Rani was killed by Mewtwo symbolizing the end of one Rani and the beginning of the next. However, the experiment was not completed as intended and Mewtwo deviated from the Rani and developed a personality and character development.