The second part of the quote reads:
An investment in knowledge always pays the best interest.
What Franklin is saying with the vivid image of opening one's head and pouring a purse full of coins inside is that it pays to spend money on educating yourself. Whether that means paying for education, tutoring, or buying books, knowledge will help you earn money in the end. And since your knowledge can never be taken away from you, it will remain a gift that keeps on giving. You can lose your farm or your business, but you can't lose what you know. If you lose your farm, say, if you have farming knowledge, you can recoup your losses and start afresh.
Franklin was a pragmatist, and issues of earning and saving money were important to him. He believed in using money wisely and believed in frugality, so if he says to spend money on an endeavor, it probably makes practical sense to do so.
However, Franklin is also here speaking on a metaphoric level: he is implying that knowledge has an intrinsic value that can enrich life and keep on doing so.