Wiki article on this topic: The cornerstone is the first stone set in the construction of a masonry foundation, important since all other stones will be set in reference to this stone, thus determining the position of the entire structure.
Over time a cornerstone became a ceremonial masonry stone, or replica, set in a prominent location on the outside of a building, with an inscription on the stone indicating the construction dates of the building and the names of architect, builder, and other significant individuals. The rite of laying a cornerstone is an important cultural component of eastern architecture and metaphorically in sacred architecture generally.
Some cornerstones include time capsules from, or engravings commemorating, the time a particular building was built.
Often, the ceremony involved the placing of offerings of grain, wine and oil on or under the stone. These were symbolic of the produce and the people of the land and the means of their subsistence. This in turn derived from the practice in still more ancient times of making an animal or human sacrifice that was laid in the foundations.
Frazer in The Golden Bough charts the various propitiary sacrifices and effigy substitution such as the shadow, states that:
Nowhere, perhaps, does the equivalence of the shadow to the life or soul come out more clearly than in some customs practised to this day in South-eastern Europe. In modern Greece, when the foundation of a new building is being laid, it is the custom to kill a cock, a ram, or a lamb, and to let its blood flow on the foundation-stone, under which the animal is afterwards buried. The object of the sacrifice is to give strength and stability to the building. But sometimes, instead of killing an animal, the builder entices a man to the foundation-stone, secretly measures his body, or a part of it, or his shadow, and buries the measure under the foundation-stone; or he lays the foundation-stone upon the man's shadow. It is believed that the man will die within the year. The Roumanians of Transylvania think that he whose shadow is thus immured will die within forty days; so persons passing by a building which is in course of erection may hear a warning cry, Beware lest they take thy shadow! Not long ago there were still shadow-traders whose business it was to provide architects with the shadows necessary for securing their walls. In these cases the measure of the shadow is looked on as equivalent to the shadow itself, and to bury it is to bury the life or soul of the man, who, deprived of it, must die. Thus the custom is a substitute for the old practice of immuring a living person in the walls, or crushing him under the foundation-stone of a new building, in order to give strength and durability to the structure, or more definitely in order that the angry ghost may haunt the place and guard it against the intrusion of enemies.