Your purse holds the amount of gold pieces that you have, excluding any gold that you hid in a bag or other container. The amount of gold in your purse appears on the status line, or you can count it by pressing $. Your purse is available for making payments to shopkeepers and priests and for bribing demons.
The purse is not an actual item. It is not visible in your inventory (though the gold in it is), you cannot drop it, and it cannot be taken from you. Nor does such an object appear anywhere else in the game. It is just a device to explain how the adventurer manages to keep their finances organized.
When a leprechaun steals your gold, the message is, "Your purse feels lighter."
Gold in your purse is vulnerable. For example, a leprechaun might steal it.
Dipping an item in a fountain may occasionally cause you to lose some of the gold in your purse ("You lost some of your gold in the fountain!"), but no more than 10% of it.
Unlike leprechaun stealing, gold lost to thrones, fountains, and spellbooks is gone forever.
When you are in situations where you might lose your gold, you can protect it by removing it from your purse. If you have a bag, you can hide your gold in there. You could also stash your gold into a chest or large box, or just drop or throw it on the floor. (Note that leprechauns can still snatch gold from underneath your feet, if you are standing directly on it.).
Since bribable demon lords only care about gold visible in your purse and will ask for an amount less than or equal to it, it may be worth carrying around a few gold pieces when you're about to encounter one, if you would prefer to pay them off.
An exception to normal purse behavior is when a vault guard demands that you drop all of the gold that you are carrying. The guard is able to sense if you have gold stored in a container and will attack if you do not remove the gold and drop it.