Towns are places where characters can gear up, rest to heal wounds, or look for new quests and information.
Treat wounds and cure poison. The more roughed up the party, the more they'll have to pay to get back into shape.
Offer many useful items. Once the menu is open, the merchant's items are shown to the left. The party's inventory is to the right.
To buy an item, drag it from the merchant's tab to the party inventory tab. To sell, do the opposite. Alternatively, SHIFT+LEFT-CLICK will do both, but there is no confirmation pop-up.
Use arrows above the party inventory to change to the equipment menu; there, you can compare equipped items with those in the shop.