At least two groups, probably more, of higher (vascular) plants developed carnivorous behaviour at the same time (Slack, 1979).
It is intriguing to wonder how this evolution occurred. Although it is difficult to come up with a definite answer, given the lack of suitable fossils, we can nonetheless offer a possible model. Let us start by assuming that non-carnivorous plants with leaves in a pitcher shape that could accumulate water, for instance, already existed. This is true of many epiphytic plants. Some insects could have accidentally tumbled in and drowned. Then as they decomposed, mainly due to bacterial action, they would have released a certain amount of various substances that had already been broken down and could be easily absorbed.
The absorption of mineral salts by the leaves, although characteristic of carnivorous plants, is not exclusive to them. Spraying leaves with nutrients, mainly phosphorus, is a well-known horticultural technique. If the decomposed substances were absorbed by the plant, that made it a carnivore, just by chance. This is probably how the first carnivorous plants appeared. As they made greater use of this additional source of nourishment, they adapted better to nutrient-poor habitats. The other morphological or physiological adaptations were the result of successive selections to improve the new means of assimilation: colour and nectar to attract prey, production of digestive enzymes, etc. Heliamphora, thought to be the most primitive genus of carnivorous plants, supports this theory. It has rolled leaves with margins sealed together to form a pitcher. In addition, it has no digestive glands; decomposition is performed entirely by bacteria.
Note that glands that secrete sticky substances are not unique to carnivorous plants. Some plants have developed such glands as a means of defence against plant-eating insects.
Reference: Slack, A. Carnivorous Plants, Mass., MIT Press, 1979, 240 p.