Barter is trading one thing for another without using money.[1] Usually the things that are traded are worth the same amount of money, but no money is used in the trade.
Barter is useful when two people each have something the other wants, so they agree on an amount of stuff and then swap it. This can also happen with services, for example a plumber can fix a tap in a winery and be given a crate of wine.
Barter and money have been practiced longer than history has, so there is little historic evidence of the change. However, the usual idea is that barter came earlier and money arose to solve a problem: One person may not want what the other person has. For instance, Bob needs a new pair of shoes and John has those shoes. But Bob has eggs and John needs milk. This is where money becomes useful because anything can be traded for a set amount of money. Bob could pay John for the shoes and John could go to the store and buy some milk.