Milton began plotting various subjects for tragedies in a notebook created in the 1640s. Many of the ideas dealt with the topic of Samson, and he gave them titles such as Samson pursophorus or Hybristes ("Samson the Firebrand, or Samson the Violent"), Samson marriing or in Ramath Lechi, and Dagonalia (the unholy rites at which Samson performed his vindication of God). The title he chose emphasises Samson as a warrior or an athlete, and the play was included with Paradise Regained and printed on 29 May 1671 by John Starkey. It is uncertain as to when the work was composed, which leaves the possibility that it was an early work that was filled with Milton's ideas about the Civil War or it was a later work that incorporates his despair over the Restoration. Evidence for the early dating is based on his early works and his belief in revolution whereas evidence for a later dating connects the play with his later works, such as Paradise Lost, and comments reflecting on the fall of the Commonwealth. In 1671, the work was printed with a new title page and prefaced his work with a discussion on Greek Tragedy and Aristotle's Poetics.
On the title page, Milton wrote that the piece was a "Dramatic Poem" instead of it being a drama. He did not wish for it to be performed on stage, but thought that the text could still influence people. He hoped that in combining Samson with traits of other Biblical figures, including those of Job or of the Psalmist, he could come up with the perfect hero who could deal with complex theological issues. In writing the poem, Milton, in choosing the character of Samson as his hero, was also illustrating his own blindness, which afflicted him in his later life.