Carl Menger, the founder of the Austrian School of economics developed the economic theory of the origin of money. He argued that for something to emerge as a medium of exchange, it must have existing exchange value. Otherwise, people would not know how much of it to give in exchange for things they buy or take in exchange for things they sell. In order for something to have existing exchange value, it must currently be traded on the market or be introduced as a claim to something currently traded on the market. So gold originated thousands of years ago as a medium of exchange because it was already being traded as a good in markets, was highly marketable, and had desirable properties as a medium of exchange, e.g., durability, divisibility, portability, and so on. Once gold coins existed as money, claims to gold coins can come into existence. Bank notes or checkable deposits are money substitutes as long as people trust that the issuer will make good on his claim to redeem them for gold coins. Fiat money comes into existence first as a money substitute claim for existing money and then the issuer of the claim, namely, the state, breaks its claim. From that point on fiat money can continue as money without any reference to its past backing. It continues as money solely because people anticipate that other people will continue to accept it as money in trade. Federal Reserve Notes came into existence in 1914 in exactly this manner. The Fed redeemed FRNs at par with gold coins and claims to gold coins. The government completely broke its promise to redeem FRNs for gold money in 1971. From that point on the FRNs have been fiat money. The Euro also came into existence in the same way. It started as a redemption claim for each of the national currencies of the EMU countries. Over a few years, each of the countries broke its promise to redeem Euros for its national currency. From that point on the Euro has been a fiat money.
Here is Menger on the origin of money: