And why is the lightsaber the preferred weapon of characters the Force (filmmaker) favors?
Guns are awful from a cinematic point of view. You can’t defend against a gunshot, and because gunshots are almost always serious, the combatants have to either keep missing each other to string it out (in which case they both end up looking useless), or they have to accidentally drop their guns and switch to their kung-fu skills.
George Lucas solved this problem by bringing in the sword, long surpassed in the real world but still superior for cinematic purposes, and changing the rules so this archaic device was back at the cutting edge.
In the saga, the lightsaber is both the badge of Force favor -- it takes great skill and Force ability to wield -- and the most immediate benefit of having the Force with you. Hapless minor characters are forced to rely on blasters, which a lightsaber can easily reflect back.
And the action scenes are better. Lightsabers allow both combatants to be incredibly skilful and still not kill each other instantly -- as they would if they were armed with guns -- and the Force presses this advantage by bestowing multiple cool techniques on those it favors, Force-throws, jumps, flips, outright telekinesis.
Kurt Wimmer took a different approach to the same problem in Equilibrium.