The oldest temple we know about at the moment is a circular structure at the pre-pottery Neolithic B (PPN-B) site of Gobekli Tepe in Tas Tepeler region of modern Turkey. From the very beginnings of human efforts to construct permanent settlements or cities, temples have consumed a huge percentage of the available human labor and other resources.
It should come as no surprise then, that right from the start, things we started collecting as precious objects would accumulate in the temples in the greatest quantities. Long before the most precious of metal objects started their journey toward being thought of as money, temples became their repositories. Metal was stored in bulk in temples and it was used as an artistic adornment on other objects we put in such places. Thus, perhaps the only that that is surprising about the fact that relatively standardized lumps of metal would be cast or stamped with images associated with the deities of the temple cults is that it took so long for it to happen - perhaps as long as 7,000 years.
One other surprising thing about the invention of what would become coins is where it happened. The first coins appeared only a very short distance from those Tas Tepeler PPN sites in southeastern Turkey where the oldest known temples were built. A Greek culture known as the Lydians seem to have been the first to finally hit upon the idea of a coin. Religion and money have been partners for many thousands of years, and might even be said to have been invented, or at least evolved together, and under the guidance of the clergy every step of the way. "In God We Trust" seems appropriate as a monetary motto, even for someone who puts little stock in many aspects of organized religions.
As far as we have been able to determine, someplace in eastern Europe around 4,500 BCE someone hit upon the idea of purposefully blending two metals together to form an alloy. As mentioned earlier, electrum is a naturally occurring alloy of gold and silver, and using heat to separate them had been known for perhaps a thousand years or more before someone thought to reverse the process, and then try it with other metals. The Vinca culture spanned a fairly large area in eastern Europe, and in what is now modern day Serbia, bronze foil has been discovered that is the earliest example of tin-copper bronze (as opposed to arsenic-copper bronze).
Tin-copper bronze is hard, and sometime around 3,000 BCE it would become the material of choice for weaponry. By the early first millennium BCE alloys were presenting a valuation problem for the use of bullion as a medium of exchange. Gold was supposed to be worth more than an equivalent weight of silver, and silver worth more than copper or bronze, and so on. Get the equivalent valuations right using only a scale and one's ability to recognize a metal by its appearance became increasingly difficult at time went on. A new form of counterfeiting was born along with the ability to make alloys that looked convincingly pure.
The story of Archimedes discovering the displacement differences of various metals in the third century BCE is almost certainly apocryphal, but it does serve to illustrate just how serious this problem of trust in the composition of metals had become once alloys were common and bullion was being used as a primitive kind of early money. The answer to this problem that caught on and which would lead to metal coins was to certify their content. Put god's image or seal on it.
It was the Lydians who came up with the idea of god certified bullion. This idea quickly caught on. Since a significant portion of the the wealth of a community was commonly stored in the local temple, putting an image of the deity associated with that temple seemed only natural. Once the priests had been satisfied that the metal was uncorrupted by having been alloyed with another, lumps of various useful sizes were "minted" with the preferred symbol of the temple on one side. Minting was done by placing the coin blank onto a die with a reverse version of the desired image, and then striking the blank on its back with a punch and hammer. The Lydian's added one more touch that spread right along with their certification image idea. While they tried out a great many different certification images, they tried to limit the use of any one style to a lump of metal having a specific weight. Denominated coins with an image associated with a specific intended value on them were born.
The Lydian idea of using images to certify the metal content of bullion caught on quickly, and pretty soon, every monetized economy that was connected by the extended trade routes of Europe, Asia, and Africa were using coins made of crow bait. This solved the problem of counterfeiting, or at least it greatly reduced the problem. But it instantly created several new problems.
There would never ever be enough crow bait to produce all of the money needed to support the monetized economies of the world. Human market transactions have always vastly outnumbered the supply of hard currency to support them. It was literally impossible for so-called hard currencies to ever completely work as money. There just isn't enough of the raw material required to make it so.
The extreme shortage of money quite dramatically increased the gulf between the upper and lower classes because the upper classes quickly seized control of what little money there was.
The connection between stored work and money would be lost in the minds of most people. Money became its own thing, quite separate from the world of goods and services.
A new kind of counterfeiting soon developed - the shaving of coins and the molding of a higher value metal around a less rare one, or even something as common as wood in its core.
God certified hard currencies were soon joined by those certified by royalty, with the imagery of the temples being replaced by the images of royalty. it is not clear from the archaeological record if the the appearance of coins in China at about the same time was influenced somehow by the flow of information back and forth along the Silk Road, or if the idea was invented twice. There is another possibility as well.
Remember the caution on the introductory page of this story of money. New discoveries can and do sometimes require a complete rewrite of our understanding of history or anything that is the result of scientific reasoning. It is not impossible that it was the Chinese got who there before the Lydians. It does not look like that at the moment. The evidence still suggests that a proper application of Occam's Razor to the evidence we have is that the Lydians got there first, and it quickly spread through all of the cultures that were connected by extended trade networks. But, a single find with well confirmed dates could flip that around.
Despite the popularity of money as a substitute for barter transactions, and how quickly new ideas about money would spread, money was not for everyone. If fact, it wasn't for hardly anyone at all.