The devil's beating his wife

When it is raining and the sun is shining, why do people say, "the devil's beating his wife"?

From the archives:

devil is whipping his wife -- Said when it rains while the sun is shining; the rain is supposed to represent the tears of the devil's wife.
From The Facts on File Dictionary of Regionalisms by Robert Hendrickson.