Bees evolved from earlier flies and dragonflies about 200 million years ago. They developed the ability to take advantage of a new food source: flowering plants like apple trees and grass and daisies. Bees developed the ability to eat the pollen that these flowering plants made, and the bees and the flowers worked out a relationship that is good for both the bees and the flowers, where the bees help the flowers to reproduce.
Over time, some of these bees evolved into ants.
To find out more about insects and crabs, check out these books from Amazon.com or from your library: