Erosion of a cliff in Canada
When the Earth first formed, about four and a half billion years ago, it was all liquid rock and liquid metal because it was so hot. But when the Earth cooled down, around four billion years ago the igneous rocks formed - granite and quartz and lava and other kinds of rock. When the wind blew on these rocks, and when the rain washed over them, little bits of rock gradually broke off - that's what erosion is.
Little by little, these eroded bits of rock rolled or blew down from the mountain tops to the river valleys, and then the rivers carried them along the river valleys to the ocean. They mixed together to make sand and clay, and mixtures of sand and clay. A lot of the sand and clay ended up on riverbanks and on beaches, where you see it today.
A sand beach in Oregon
Some of the sand and clay fell into lakes and oceans, where gravity pressed the water down on top of the sand and clay and mashed the particles together into new rocks. These are sedimentary rocks like sandstone (made out of sand) and shale (made out of clay).
Beginning about a billion years ago, there were plants on land, and when these plants died, the dead plants mixed with the sand and clay to make dirt. Like the sand and clay, dirt tended to fall or blow down from the tops of hills into river valleys, and then to be carried in the water along the river valleys to the oceans. That's why when people came along about 150,000 years ago, they found the best land for hunting and gathering, and later for farming, was in river valleys, especially near the ocean: the early cultures of the Egyptians in the Nile valley, or the Sumerians in the valleys of the Tigris and Euphrates rivers, or the Bantu along the Niger river, or the Woodland culture along the Mississippi River, or the Harappans along the Indus river are all examples.