How do multiple beams of eldritch blast work with a Pact of the Blade weapon? When I, as warlock, have my Pact of the Blade rapier in one hand and cast multiple beams to hit either single or multiple enemies, do I need to drop/sheathe my sword to do these multiple beams with two hands?
You need only one hand free
Each spell's description indicates whether it requires verbal (V), somatic (S), or material (M) components.
Spellcasting gestures might include a forceful gesticulation or an intricate set of gestures. If a spell requires a somatic component, the caster must have free use of at least one hand to perform these gestures.
As you can see from this description, only a single free hand is needed to cast a somatic spell. The fact that Eldritch Blast can launch multiple beams does not mean you need more free hands to launch them. Nothing in the description of Eldritch Blast suggests more free hands are needed, the beams are simply launched, so you only need one free hand and can be holding your pact weapon Rapier in the other hand when casting Eldritch Blast
Yes, you can.
The spell Eldritch Blast is listed as having Verbal and Somatic Components. Under the rules for Somatic Components, you can see the following rules text:
Spellcasting gestures might include a forceful gesticulation or an intricate set of gestures. If a spell requires a somatic component, the caster must have free use of at least one hand to perform these gestures. (Basic Rules, p. 83)
As a result, as long as your character has at least one free hand, you are able to cast the spell. The spell then does what it says it does, and if you're of a sufficient level, it produces the extra attacks. You do not need to have additional hands free to make these attacks, since it doesn't say that you do.