Because in the movie, while (not necessarily spoilers) Finn, (token black guy. Great character) is running across a battlefield of an invasion on the soil he stands upon, a grim battle turns into a "what the **** that's awesome" battle when traitor trooper shows up.
Traitor trooper then proceeds to beat Finn (traitor of the glorious first order, rebel scum) into a proper pulp.
You find out Finn is a traitor when you meet him. So like I said, only spoiler I guess with what you asked for.
Unless you're a Jedi/Sith, it's pretty useless to use a melee weapon in a battle in the Star Wars universe unless you have the element of surprise. You would likely get shot if you threw down your gun and pulled out a melee weapon. Unless you have the force, it is very impractical. Very low chance of dodging/deflecting any shots that tend to be a 1-hit kill unless your a main character.