There are six characters in all that need to be freed from the brig. This will be done while in the hub and not in story or free play modes. The brig is located on the Republic Ship Resolute.
To get there from the main hub, go down the elevator on the left and once through head to the right at the bottom of the screen. Use gold bricks to open the corridor and there you have it. The first four characters are unlocked by completing the story mode and viewing their respective cutscenes.
Poggle The Lesser
Dr. Nuvo Vindi
The last two are unlocked by completing Ground Assault Levels for the Republic.
Nute Gunray - Naboo Level
Whorm Loathson - Christophsis Level
You will need Bounty Hunters, Charge Characters, Droid Characters and Sith Characters to free them and purchase them once you've unlocked them.
Each cell needs to be unlocked and the methods for doing so are fairly straightforward with the exception of the second cell from the right. You have to use a Sith character to rotate the dial with the blue lights on it clockwise until the four corners are lit as well. Then use a Droid character to open the cell.
Note that for that cell I used Anakin with the Red Power brick for Dark Side activated, if you find you are having trouble. Try moving around a bit too if you find you can't highlight it immediately.