James Jones took the title for From Here to Eternity from an 1892 poem by Rudyard Kipling entitled "Gentlemen Rankers." It's framed as a song sung by soldiers in the British imperial army. The verse in question reads:
Gentlemen-rankers out on the spree, Damned from here to Eternity, God ha' mercy on such as we, Baa! Yah! Bah!
It's interesting, because these soldiers are saying that they're "damned from here to eternity"—which, presumably, isn't such a nice thing. If you didn't know the context, you'd look at the title and probably think that it was referring to immortality in a more positive way, meaning that people won't forget the service rendered by these soldiers "from here to eternity."
And, in a way, that also is what the title means, as far as the movie version of From Here to Eternity is concerned—it's a timeless story. But it's funny to note the darker origin of the term.
It's also funny to note the phrase Baa! Yah! Bah! (what does it mean?!).