This phrase is typically used to describe someone who loses their money quickly, either by being tricked or spending it wastefully.
There are wise and not-so-wise ways to spend one's money. For instance, would you deem it foolish for someone to spend money on certain necessary things, such as food, water, or clothes? Probably not. However, if a person were to lose their money by betting a chunk of it on a horse race, gambling it away at a casino, or by spending it wastefully on things that are not needed, well, some would consider that to be unwise. Hence, this phrase likely originates from a basic observation: when people act foolishly with their money, it doesn't last very long.
As for the history of this phrase, it is over 450 years old! This expression has been around since at least the year 1557, as it was used by the poet Thomas Tusser. He wrote a poem called Five Hundred Points of Good Husbandry, and the saying can be found within:
"A foole and his money be soone at debate: which after with sorow repents him too late."
The wording is a bit different, but ultimately, it's similar to the saying we use today.
Note: A phrase's origins are, much of the time, very uncertain. The origins you see listed are the more plausible theories that are floating around for how or where an expression came to be, but just remember, theories are not always fully accurate! The quotes which have the phrase in them are the oldest written forms of the phrase I could find, but thre's always a chance of an older recording being out there. Perhaps I've missed it. Feel free to let me know if you know of any!
Also, remember that just because you see an idiom in some old book or newspaper, let's say they're from the year 1893, well it doesn't mean the saying originates from that source. In all likelihood, if an expression is already in use in a book or newspaper, then it's probably older. Nevertheless, these old quotes serve as a way to show the reader how far back in history some of these sayings go, which can be quite interesting!