It depends on your faith. Most Catholics believe that God created the Earth. More can be read about this in the Holy Bible. Other religions believe that it was created by different gods or all powerful beings. If you are atheist, or do not believe in creationism, most likely you believe that there was a Big Bang, and many many particles were created in space. These particles collected and changed through a complicated process that then, over eons and eons, formed the universe as we know it.
You have a few of options to find your answer. 1. Watch the SyFy channel. 2.. Pick up the bible and read for a while. 4. Look around at the sky, the stars, and the earth. 3. Search within yourself and find what fits.
God created it ... over millions of years ... in a swirling accretion disk of gas and dust, through gravity the dust clung together to make sand, then the sand stuck together to make pebbles, then the pebbles got together to make rocks, then the rocks became boulders and they all stuck together and used gravity to pull each other in until there was one big molten ball of rock. Each of these pebbles had a tiny droplet of water, when they hit the earth it turned into steam, after millions of years the steam turned into rain and after millions of years of rain we had oceans.
Since none of the religions are in agreement it might be better to go with the Big Bang.
Or, if you want to be creative yourself and combine the two, there's a more recent fable that a race of super beings were feasting on burgers, beans and beer when one of them, in a dreadful display of bad table manners, permitted the eructation that we call the Big Bang.
This gave rise to a rather strange cult called the Flat Earth Society whereas, in reality, they should have named themselves the Flatulent Earth Society.