The Earth was thought to have been formed about 4.6 billion years ago. Massive asteroids colliding together created a massive ball of molten metal and rock at the core of our planet. After a long time the outer layer also called the crust cooled to form what we know today.
Earth wasn't always how it looks now, it was once a massive super continent as seen on the photo above. We know this by how the land we have today sort of fits together and in the places where they join there are the same fossils and the same rock type. Now the continents have drifted apart because of continental drift, this is where the magma comes up from the core and pushes the tectonic plates around the world. As the tectonic plates have been pushed apart they could come back together or as equally will split apart even more than it has all ready, but there isn't an infinite amount of room so the will collide again some day.