@TylerJamesYoung's answer is 100% correct.
Here's a little more about how to parse the sentence's grammar:
The Devil was sick, and a saint he would be; the Devil was well, and the devil a saint was he!
The semicolon separates two ideas in this sentence. Since we're using the past tense, we should probably understand the sentence as talking about two different times in the past --- once when the Devil (Lucifer) was sick, and once when he was well.
One time Lucifer was sick, and a saint he would be. Another time Lucifer was well, and the devil a saint was he!
In this context, "would be" idiomatically means "would like to be" or "promised to be". (Compare "The Man Who Would Be King", or how we might say that someone was "a would-be actor".)
One time Lucifer was sick, and a saint he wished to be. Another time Lucifer was well, and the devil a saint was he!
The object and verb in the second halves of those sentences were reversed, just for the sake of making them rhyme. Let's undo that. Also, "well" in this context means "healthy", of course:
One time Lucifer was sick, and then he wished to be a saint. Another time Lucifer was well, and the devil he was a saint!
Lastly, as @TylerJamesYoung says, there's an idiomatic phrase "the devil X!"; its meaning is basically "certainly the opposite of X!" The phrase is mostly obsolete (at least in the U.S.); it's been replaced by "like hell X!"
One time Lucifer was sick, and then he promised to be a saint. Another time Lucifer was well, and do you think he was a saint then? Like hell he was!
The meaning is indeed basically equivalent to "There are no atheists in foxholes", but phrased as a little poem (one might say "a bit of doggerel") instead of a prose proverb.