Earth was formed approximately 4.6 billion years ago, likely as the result of a supernova (star explosion). The debris from this explosion began to collapse in on itself due to gravity, forming the sun. Gravity continued to draw the remaining particles together, clumping them into larger bodies, ultimately forming Earth and the other planets in our solar system.
License: CC BY-NC-SA by Khan Academy