Where was the earth formed?
Where it now exists.
Prior to the existence of any of the planets there were large amounts of dust and rocks circling the sun. These bits of dust and rocks collided but rather than splintering the held together, first by small amounts of gravity but as they grew by greater and greater amounts of gravity. The scenario is true for the first four planets of our solar system.
The asteroid belt gives us clues about such formation. It is thought they may be the remnants of this period, of a what might have formed into a planet but did not.
All four planets also grew through a very high volume of collisions with meteors and comets. Where the earth is concerned, it is believe that all our water came from those comets.
Towards the end of the earth's formation it is also believed that one particularly large asteroid collided with the earth roughly where the Pacific Ocean exists today. It was a glancing blow which took a part of the earth with it and became the moon. But scientists also believe we once had a second moon, considerably smaller than the first. That moon and our present day moon existed in the same orbit but the smaller moon was traveling at a slightly great speed.
Over time the smaller moon collided with the larger and the two combined to form what we know today. The reason they believe this is that the dark side of the moon has almost no impact craters. Had the moon been a single planet from its formation it would be uniformly pock marked with craters and yet it is not.