The following is from Karen Armstrong's book, The Case for God, which makes a case for art:
"If the historian is right about the function of the Lascaux caves, religion and art were inseparable from the very beginning. Like art, religion is an attempt to construct meaning in the face of the relentless pain and injustice of life. As meaning-seeking creatures, men and women fall very easily into despair. They have created religions and works of art to help them find value in their lives, despite all the dispiriting evidence to the contrary."
So the next time you despair about your painting, take a long view, keep on working, and see that you are doing the right thing.