Before, when the world was lifeless and dull, there was a God created by the elements of the earth being mixed together. The God then became lonely and created other Gods and deitys.
While all the Gods were being created, when the elements were being mixed around a muddy sea was created. But the world was still a shapeless chaos that needed order and structure.
The older Gods/Kami assigned 2 Gods, Izanagi and Izanami, to bring order and structure to the world by using the power of a jewelled spear. Izanagi and Izanami formed most of the earth and created many huge mountains and islands.