You can buy items from NPC's and sell the items that you do not want any longer to some NPC's.
Click on the merchant NPC who is selling the item you want. His/her inventory will be on the left, and yours on the right.
Right click on the item you want to buy, this item will be in your inventory.
Or drag it to your inventory and click to put it.
Drag this item to merchant NPC's inventory and release to sell.