Why could Paul rejoice even while imprisoned and facing possible death?

Because the gospel was spreading throughout the Roman Empire and people were coming to Christ.

Watch the Teaching: Why Paul Warns Believers to Beware of Dogs