2-1B is an NPC, a medical droid working with the Rebels.
The Enemy Let Slip Edit
After spending the night out in Hoth's blistering cold, Han and Luke were taken back to the Rebel base, and Luke was placed in a tube filled with healing fluid. Han tried to talk Luke into going with him to a "Dagger Bar", but the medical droid 2-1B pointed out that Luke couldn't hear him because he was in an induced coma.
The next day, after Luke recovered, Luke was getting ready to leave the medical facility and asked 2-1B if he was evacuating too. 2-1B said he was and had just initiated evacuation protocol mu-gamma. Then, he realized that was actually a pre-colonoscopy procedure and suggested Luke might want to regurgitate those tablets 2-1B gave him.
After the Rebels had retreated from Hoth and regrouped at a rendezvous point in space, they were eventually joined by Chewbacca, C-3PO, R2-D2, Princess, Luke, and new recruit Lando, all onboard the Millennium Falcon. Luke had recently lost one of his hands in a duel with Darth Vader. 2-1B provided Luke with a new cybernetic hand.