If you want a pretty cool example, Le morte d’Arthur was written in prison.
Antonio Gramsci - Selections From The Prison Notebooks. Phenomenal work on cultural hegemony, intellectual leadership and strategy for revolution.
Bertrand Russell wrote the book “Introduction to Mathematical Philosophy” while he was in prison. This book, published in 1919, explores the foundations of mathematics and logic. It was one of Russell’s major works and contributed to the development of mathematical logic and philosophy of mathematics.
The only one I know is Mein Kampf… And that one fucking sucks
Alexander Berkman - Prison Memoirs of an Anarchist (1912)
Berkman was in prison for the attempted assassination of union buster Henry Clay Frick, in 1892. He was sentenced to 21 years and served 14. The book is an amazing insight into the American prison system of the time.
Eugene Victor Debs - Walls and Bars (1927)
Debs was a very interesting figure and Socialist leader. Sentenced to 10 years in prison, in 1918 (under the Sedition Act), for publically denouncing the USA’s involvement in WW1, and telling people to stand against the military draft. This is part of his final speech to the Judge. Gives me goosebumps:
“Your Honor, years ago I recognized my kinship with all living beings, and I made up my mind that I was not one bit better than the meanest on earth. I said then, and I say now, that while there is a lower class, I am in it, and while there is a criminal element, I am of it, and while there is a soul in prison, I am not free.”
Technically, I think he wrote this post-release, but it’s about the prison system he experienced first hand.
Marco Polo - The Travels of Marco Polo (c.1300)
Pretty self-explanatory.
Gregory David Roberts - Shantaram (2003)
Started in prison, finished and published on the outside.
For those of you who speak Dutch: check out Roger Van de Velde. He was in prison and institutions for almost all of his adult life and wrote some truely amazing work.
Uitgeverij Vrijdag recently republished some of it. I can recommend ‘Scheiding van goederen’ and ‘De knetterende schedels’.
Not sure if he was formally writing them or just developing ideas at the time, but it is well known that Dostoevsky was nearly executed as a young man for the crime of running in literary circles that criticized the Tsar. He was spared the firing squad but was in a prison camp for several years.
Many of his later famous works including Crime and Punishment and The Brothers Karamazov seem at least tangentially inspired by this experience.