Resin is a mixture of organic compounds secreted by many plants, especially coniferous trees.
Plants evolved many complex chemicals as defences against herbivores. That may be the origin of these resins, which are certainly not good to eat. Plants secrete resins for their protective benefits in response to injury.