The majority of this work was written by Bunyan whilst he was imprisoned as a Nonconformist following the Restoration of 1660. Bunyan's experiences of persecution are deeply inscribed into his Christian allegory. It is a spiritual autobiography by a remarkable man who refused to allow anything to compromise his principles.But it is also a work that is acutely perceptive and revealing about the psychological condition of the radical Protestant of his time. The visionary society of the English Republic had collapsed and Puritans were no longer the dominant force in society. The pressure was on Bunyan and other spiritual leaders among the Puritans to enthusiastically justify their beliefs and demonstrate their righteousness, as well as their radical credentials.
Bunyan's allegory is sometimes criticised for being too one dimensional, but there is a very good reason that this is one of the most highly read books in English. People in his own time could read between the lines and understand the allusions and social and historical forces that move behind the language; and his contemporary readers share with people since a sympathy in the spiritual experiences described allegorically in what is actually quite a good story.
Though the allegory is ostensibly not as deep as, say, Milton's in Paradise Lost, it is perhaps fair to say that it's tighter and more coherent. The importance of this work as literature cannot be denied, whether or not you agree with the sentiments or accept one's own removal from Bunyan and his contemporaries in history.