The purpose of cave art was most likely the ancient peoples way of recording events. It also was probably used for storytelling. As there was no written language when the paintings were done, cave paintings were their way of recording things.
It is also believed by scientists that cave paintings were part of a hunting ritual. Ancient people believed that if an animal was painted on the walls, and then they went off to hunt, the animal would come off the wall, creating more game to hunt. As many people point out, the animals are extremely detailed, but the humans seem almost sloppy. This might have been their way of preventing the creation of humans off the walls.