Story starts when Luffy reaches level 6 of Impel Down. Trying to rescue Ace he notices that he’s too late.
Luffy realeases Sir Crocodile and Jinbei to get out of the prison when he hears someone else call from a neighboring prison.
Getting closer he sees a young man sitting there, his black hair in a pigtail and wearing Chinese clothes (guess who). He say he’s called Ranma and offers his help for his freedom. No one knows who Ranma is, but Luffy doesn’t see a reason not to free the unknown man. While they run away Ranma Luffy’s getting curious and Ranma quickly tells him why he was imprisoned. Satisfied with the answer, Luffy doesn’t ask any other questions and while they are still running Ranma thinks back to his arrival in this world and all that has happened to him here.
In this story Ranma is neither a pirate nor does he work for the World Government. But thinking back to the injustice of his imprisonment, just for doing what is right he might join Dragon and participate in the revolution.
Ranma was convicted because he knocked down a Tenryuubito who was about to shoot one of his slaves just for dropping a bag. Since attacking a Tenryuubito is a crime Ranma was quickly attacked by the Marine but he had no trouble dealing with them, and even Aokiji is powerless. He gets away and the Marine put a hefty bounty on his head.
A few days later he’s ambushed by a massive Marine force that even he can’t deal with and imprisoned in Impel Down.
The reason why Aokiji was powerless against Ranma is because of his own devil fruit ability. Ranma ate the ‘null null fruit’. It’s not a power up but makes Ranma immune to direct attacks by other devil fruit users.
For example, Ranma is completely immune to Ace’s fire ability, but if he’s in a burning house he can still be killed by the fallen debris.