In the early 17th century, The Netherlands was still at war with Spain, whom were surpressing the little Republic for years. On top of the war with Spain, a great theological controversy broke out between moderate Jacobus Arminius, a theology professor at Leiden, and his followers (who are called Arminians or Remonstrants) and the strongly Calvinist theologian, Franciscus Gomarus (whose supporters are called Gomarists or Counter-Remonstrants).
Grotius was a moderate believer and plead for tolerance between religions, and supported the Remonstrants. When Spain and the Netherlands agreed to an armistice in 1609, the Remonstrants aimed for permanent peace. Dutch Prince Maurits, however, who was the military commander, needed the war to keep up his power. Even if he had no clue about religion, he supported the Counter-Remonstrants, since they were pro-war. In 1618, Maurits couped.
This had bad consequences for Van Oldenbarneveldt and Grotius: they were accused of high treason. Van Oldenbarneveldt was beheaded publicly in 1619, a day after his conviction. Grotius was convicted to lifelong prison in Loevestein Castle, a state prison at that time.
He wasn't planning on staying there until his death, though. He lived there with his wife Maria and their maid, Elselina. Grotius was allowed to study in his prison cell, and he regularly received a large chest of books to this aim, which was later returned to the sender in Gorinchem, a city across the river. This eventually brought Maria to an idea: Grotius should hide in the book's chest and escape. She let him practice for days, in order for him to stay in the chest without making any sound. The escape succeeded on March 22, 1621. He fled to Antwerp and then Paris, where he met his wife again.