Excerpt taken from Inner.org:
Rabbi Menachem Nachum of Chernobyl dedicated much of his life's work to redeeming imprisoned Jews. In those days, if a Jew could not pay his debts to the local landlord, he was often thrown mercilessly into a dungeon or pit, sometimes with his entire family. Rabbi Nachum raised money to redeem these unfortunate Jews, saving them from sure death. Our sages say that there are two commandments that are called "great mitzvot." The first is the commandment to procreate, and the second is the commandment to redeem imprisoned Jews. When one redeems a Jew, thereby saving his life, it is as if he given birth to his soul.
It came to pass that Rabbi Nachum was also imprisoned. Daily he would bribe the prison warden to let him out of the pit for a short time to pray and to immerse in the mikveh. One day, Rabbi Nachum did not bribe the warden. He explained that he did not need to do so, for he would be released from prison on that very day. When asked how he knew that he would be released, he related that on that night Sarah had come to him in a dream. Rabbi Nachum asked Sarah what he did to deserve being thrown into a pit. Sarah answered that because Rabbi Nachum had devoted his life to redeeming captives, it was necessary for him to experience a taste of captivity so that he could consummately understand the situation and subsequently devote himself to this mitzvah in an even more rectified manner. When a person understands why God has involved him in a certain situation, this releases him from the situation. Thus, as soon as Rabbi Nachum understood the reason for his imprisonment, he knew that he would be released on that very day.