The scene was supposed to be a long drawn out sword fight. But Harrison Ford was hungover and not really ready for the action, so he ad-lib'ed pulling out the pistol and shooting the Arab.
Spielberg liked the idea and left it in.
Necessity IS the mother of invention!