Yes, some of Paul's letters were written while he was in prison - and it always strikes me how joyful and at peace he was, in spite of his circumstances. Typical were these words written from prison to the Christians in Philippi: "Rejoice in the Lord always. I will say it again: Rejoice!" (Philippians 4:4).
Paul's only "crime" was preaching the Gospel - which some people violently rejected. Remember: The first Christians lived in a world that didn't believe Jesus was who He claimed to be - the Son of God, sent from heaven to save us from our sins. The Romans had their own gods and goddesses, and were threatened by Paul's message of repentance and faith in Christ. Some even claimed Paul and his fellow workers were dangerous to society.
Christians are still persecuted for their faith in some parts of the world. In fact, more people have died for their faith in Christ in the last 100 years than in all the other centuries since Christ. The Bible warns, "Everyone who wants to live a godly life in Christ Jesus will be persecuted" (2 Timothy 3:12).
What about you? No matter who you are or what you have done, God loves you, and Christ gave His life to forgive you. If you haven't done so, confess your sins and open your heart to Jesus Christ today. Then ask Him to fill you with His joy and peace every day, no matter what others think.