This story is highly simplified, and each stage in it is under detailed investigation by different sets of specialists. But the outline, for our purposes, is sound.
Earth was not around at the beginning—the universe began without us some 10 billion years earlier than Earth. The universe started out with only two elements, hydrogen and helium gas, which formed stars that burned these elements in nuclear fusion reactions. Generations of stars were born in gas clouds and died in explosive novas. The conditions in those novas produced the heavier elements we have with us today. This is well-documented cosmology and astrophysics.
Long, long ago (some 5 billion years ago) in a perfectly ordinary place in the galaxy, a supernova exploded, pushing a lot of its heavy-element wreckage into a nearby cloud of hydrogen gas and interstellar dust. The mixture grew hot and compressed under its own gravity, and at its center a new star began to form. Around it swirled a disk of the same material, which grew white-hot from the great compressive forces. That new star became our Sun, and the glowing disk gave rise to Earth and its sister planets. We can see just this sort of thing happening elsewhere in the universe.
While the Sun grew in size and energy, beginning to ignite its nuclear fires, the hot disk slowly cooled. This took millions of years. During that time, the components of the disk began to freeze out into small dust-size grains. Iron metal and compounds of silicon, magnesium, aluminum, and oxygen came out first in that fiery setting. Bits of these are preserved in chondrite meteorites. Slowly these grains settled together and collected into clumps, then chunks, then boulders and finally bodies large enough to exert their own gravity—planetesimals. This whole process is rather well modeled by scientists like those at the Planetary Research Institute.
As time went by, planetesimals grew by collision with other bodies, and as their mass grew larger, the energies involved did too. By the time they reached a hundred kilometers or so in size, planetesimal collisions produced a lot of outright melting and vaporization, and the materials—which we can confidently call rocks and iron metal—began to sort themselves out. The dense iron settled in the center and the lighter rock separated into a mantle around the iron, in a miniature of Earth and the other inner planets today. Planetologists call this differentiation, and it is documented not only for the planets, but also for most of the large moons and the largest asteroids (from which come iron meteorites). The asteroids Ceres, Pallas and Vesta survive from that time, miniature planets.
Earth Is Born
At some point during this time, the Sun ignited. Although the Sun was only about two-thirds as bright as it is today, the process of ignition (the so-called T-Tauri phase) was energetic enough to blow away most of the gaseous part of the protoplanetary disk. The chunks, boulders, and planetesimals left behind continued to collect into a handful of large, stable bodies in well-spaced orbits.
Earth was the third one of these, counting outward from the Sun. We know that the process of accumulation was violent and spectacular, because the smaller pieces left huge craters on the larger ones. Our studies of the other planets in the Space Age document these impacts everywhere we've looked.
At one point early in this process a very large planetesimal struck Earth an off-center blow and sprayed much of Earth's rocky mantle into space. The planet got most of it back after a period of time, but some of it collected into a second planetesimal circling Earth. It's still there—it's the Moon. Since this theory took center stage in the mid-1980s, it has become everyone's favorite. And as geophysicist Don Anderson once explained, "The objection that such an event would be extremely rare is actually a point in its favor, since the Moon is unique."
The oldest surviving rocks on Earth were formed some 600 million years after Earth first formed. So all of the activity of Earth's birth was already ancient history (except for a possible "late bombardment" of the last stray planetesimals around 4 billion years ago). The oldest rocks, dated by the uranium-lead method as about 3.96 billion years old, show that there were volcanoes, continents, oceans, crustal plates, and life on Earth in those days. While the eons that followed were full of strange stories and far-reaching changes, the Earth had taken on its basic structure long before.
PS: The evidence for this story is not the kind of things that geologists find visible in rocks. It's the result of patient evidence-collecting from meteorites and the geology of the other planets, analyses of very large bodies of geochemical data, and generations of serious argument among many different sets of specialists. You can take it or leave it, since it doesn't affect the price of beans, but if you want to learn science or have it taught in your schools, this is the story of Earth—this and no other.