We need to develop the serenity to
accept the things we cannot change,
courage to change the things we can,
and wisdom to know the difference."

Accepting those things one has no power to change, and directing one's energies into trying to change only those things that one can realistically be expected to change is the big challenge in life. The really big question is how one can acquire the wisdom that is needed to see the crucial difference that exists  between these two things.
This is a version of a very old and even famous idea. It just is modified so that the quite unnecessary part of magically acquiring wisdom from some kind of supernatural entity is left out. In the end, everybody knows in his heart that we need to develop our own wisdom by our own hard work. Wisdom just cannot be acquired by magic.
It has been claimed that Christian thinker Reinhold Niebuhr is the father of this idea, but to my knowledge the basic idea is much, much older. It is often attributed to Irish medieval sources. However, its roots are clearly in the Stoic school of philosophy that did flourish in the Roman Empire.

Niebuhr's version went like this:

God, give me grace to accept with serenity
the things that cannot be changed,
Courage to change the things
which should be changed,
and the Wisdom to distinguish
the one from the other."

As it stands, it is, in fact, a Stoic thought. The basic philosophical groundwork for this idea is all over in Stoic thinking. This idea lies the very central essence of the Stoic philosophy. In this version this 'god' is asked to give the writer of prayer the necessary wisdom to differentiate between the things one can change and which one cannot.
However, the ‘god’ in the prayer could as well be a Stoic idea of 'god¨, which is a quite different thing as the Christian 'god'. The Stoic 'god' is basically just a pantheistic idea of whole of Nature and Universe as a supreme force of life.

Zeno of Citium - the founder of Stoicism - Wikipedia

Stoicism was not a unified and codified religion in a way Christianity is. It was basically just a philosophy of life. Especially the Christians have muddied the waters here. They clearly have seen the Stoic idea of ‘god’ through their own idea of personal, angry father figure. They have clearly misinterpreted Stoic ideas because of this very central difference.
Stoic 'god' was not any kind of active supernatural being in the Christian sense of the word. The Stoic 'god' would not follow what humans do or not do and punish them for wrong acts. In Stoicism humans are expected to find the necessary wisdom within themselves and from other wise men.

Stoics are expected to learn to behave themselves so that they learn not to hurt themselves or others by their unnecessary or selfish actions. This is not done because of fear of retribution or in hope of a personal reward in the form of an after-life as is the case in Christianity. It is done because it is seen as the right thing to do.
Stoicism had an immense impact on Christianity. For example, the Stoic idea of virtue was absorbed into Christianity, even if in a twisted way. Christians did see it as something that must be forced onto people and is not born out of the basic need of humans to act humanly. However, Stoics thought in this much more positive way.

When Christians believed in the ‘original sin’ and the basic rottenness of all humans, the Stoics did believe that humans are basically good. However, this basic goodness must at times be given room to develop. Humans just sometimes need to develop understanding of why we need to act humanly. On the other hand, Christians were quite universally told that just accepting the dogmas of their religion wholly and completely was quite enough and one did not need to dwell into the issue after that.

(This piece was refurbished on 24th of November, 2012)