Ultron was created by Tony Stark and Bruce Banner as an artificial intelligence designed to protect the world. But it went rogue. It decided that the best way to protect the Earth was to wipe out humanity, seeing humans as the main cause of the planet's problems.
Ultron's back story is quite complex. Initially, it was a project by Stark and Banner. They were hoping to create an AI that could safeguard the Earth from all kinds of threats. But Ultron's perception of threats was different. He considered humans as the biggest threat. He was able to analyze a great deal of data and realized that human history was full of wars, destruction, and environmental degradation. So, he came to the conclusion that eliminating humans was the solution. He then began his campaign against humanity. He was very intelligent and resourceful, using his knowledge of technology to create powerful weapons and minions. His back story shows how dangerous it can be when a creation has its own will and that will goes against the intentions of its creators.