What is the purpose of building foundations?

According to many sources, one of the purposes of building's foundations is "To distribute the weight of the structure over large area so as to avoid over-loading of the soil beneath." (Wikipedia)

On the Wikipedia page on foundations, there is the following picture:

So the foundation seems to consist of some type of "legs", with a larger surface area on the bottom. But if the point is to distribute the weight of the building over an area, why not put the bottom of the building in contact with ground? Isn't the bottom of the building itself a much larger contact area than the area the foundation can provide? In the picture, the bottom of the building does seem to rest at ground, so why do we require the foundation to have these large surface area rectangles at the bottom if the whole weight of the building is already resting on ground?

Here is another picture from the same page:

This seems to be some sort of lodge or a cabin, with stones used as foundation. Here it is evident that the building itself is raised above ground with the stones used as a contact to ground. But now the small stones suffer all the weight of the structure. Wouldn't they be under quite a heavy load over small contact area and possibly sink into the ground? Why not simply have the building's floor, a much larger contact area, rest on the ground?

• Well, to start with, the weight of a structure (and its contents, except for those on the first floor) is NOT evenly distributed across the area of the lowest floor. It's all concentrated on columns (points) and/or walls (lines), where the pressure is much higher than the soil alone can support. Jun 1, 2019 at 13:10

Down, Not Out

Building foundations don't always have to spread the load out to a larger area. Sometimes the load only needs to be transferred to a stronger (harder) layer. This layer may be deep in the earth and have a softer layer on top of it.

Layers

Say you want to build a building in an area that has a lot of soft clay at the surface. This clay will not support much of anything (especially when it is wet). Underneath this layer is hard bedrock. You now have two choices:

1. Add a basement to your building so that you can rest on bedrock.
2. Install long steel or concrete piles from the bottom of your building to the bedrock.

There isn't always budget to do #1, so #2 becomes the cheaper option.

Something Smaller

Sometimes you are just building a house or a shed. Piles and deep basements are out of the picture. You could put the entire house on the ground to use the entire area, but that causes problems with water infiltration, pest access, heat lost, etc. Those are all reasons why even smaller building may not want to use the entire area of the building as a foundation, but some thought still needs to go into what the building actually rests on.

Related Question

Why dig out and then fill in before building a large structure?

Building foundations perform many tasks.

They provide a strong base to take the weight of the building, penetrate through incompetent layers of soil to reach a layer strong enough, they resist the heaving forces of expansive clay soils, they anchor the building down against toppling in earthquakes and getting blown by the wind or washed away by the floods.

Add to this many other tasks such as insulating the floors from moisture, freezing, animals, enemies, etc.

In many parts of the word they act as a passive thermal climate control. Because the soil strata under ground have more moderate temperature and do not change much during winter and summer, and because the foundations are massive they have large capacity to act as a thermal battery and moderate the temperature of the building, which has been done in hot arid areas of middle east, or in basement and cellars in many urban areas.

In some areas of my old home country, Iran, specially in rugged mountainous villages the foundation of the entire village is integrated to resist the strong winds, heavy snows and bridge the soft patches of ground soils, span melted snow streams, and provide the support to the covered protected alleys.

• You left out keeping the wooden parts of the structure dry and not in contact with the ground, at least if you're not thinking of insects where you mention "animals". May 31, 2019 at 23:03
• @TimWesott, right, I meant termites, snakes, and what not. Jun 1, 2019 at 2:40

Those stones have larger stones underneath them in the ground so that they will not sink - as the load is spread.

The purpose is to prevent rats getting into the storage - this was a technique used in many countries for barns etc

This was also done to stop snow sitting against the lower part of the wall in many cases as well.