It is a natural substance used by the plant to defend itself against pests and diseases.
This is why tomatoes were once considered poisonous, but as they ripen, the amount of tomatin decreases.