Like Mercury and Venus and the other planets that go around the Sun, the Earth probably formed a little more than four and a half billion years ago (about 4,600,000,000 years ago). Like the other planets, Earth is made of molecules that were floating around in space in a nebula cloud of dust that was the leftovers when our Sun formed.
At first, just a few molecules clumped together. Then the clumps began to crash into each other and stick together to make bigger clumps. After a while there were big crashes as pieces of metal and rock hundreds of miles across smashed into each other. Finally they were big enough to be a planet.
The Sun's gravity caught the new planet Earth (along with other new planets like Mercury and Mars) and pulled it into an orbit around the Sun. While the Earth's momentum was always trying to carry it away from the Sun in a straight line, the Sun's gravity kept pulling the Earth toward the Sun, so that through centrifugal force the Earth ended up going more or less in a circle around the Sun, about 92 million miles (150 million kilometers) away from the Sun. (Compare the reason that electrons go around the nucleus of an atom). It takes the Earth one year to go all the way around the Sun (moving at about 67,000 miles per hour, or 100,000 kilometers per hour - about a thousand times faster than a car drives on a highway). That's what causes the seasons to change: spring, summer, fall, and winter.
In addition to going around the Sun, the Earth also spun around like a top. It takes the Earth one day (24 hours) to spin around once. That's what makes it look like the Sun rises in the East and sets in the West every day, and it's why we have day and night - night is when we are on the side of the Earth that is away from the Sun.
Here's a short video showing how the Earth orbits around the Sun (the big ball in the middle is the Sun, the colored ball is the Earth, and the tiny ball going around the Earth is the Moon).
Bibliography and further reading about planets: