"God is a prisoner too. He is inside the cell," Francis said at an audience with Italian prison chaplains in the Vatican.
"He is a prisoner of our egoism, of our systems, of the many injustices... That punish the weak while the big fish swim freely," the pope said.
He also spoke of reforms to the justice system.
"You have spoken of a justice system for reconciliation, a justice system of hope, of open doors, of new horizons," he said.
Francis has shown close attention to prison life and in one of his first acts as pope blessed the feet of young inmates at a juvenile prison in Rome as part of an Easter ritual in March.
Italy suffers from severe prison overcrowding and there are growing calls for reforms that would cut down on lengthy pre-trial detention.