When a scene is filmed, the microphones are positioned on the set solely to capture the dialogue. (Sometimes even the dialogue gets drowned out and actors need to rerecord the scene, a process known as looping). All other sounds are added by Foley artists who perform or recreate all the sounds made by actors and props (like footsteps, a glass breaking, a car door slamming, a punch, etc). The sound FX editor (or sound designer) uses computers and vast sound libraries to add special sound effects like explosions, car engines, laser blasters, lightning, and rain. Here are some of the most famous movie sound effects and how they were created.
The laser blaster from Star Wars: Ben Burtt, a veteran sound designer, climbed a radio tower and struck the guide wire with a hammer. He recorded the sound with a tape recorder and microphone (remember, this was the 70s).
The dinosaur sounds from Jurassic Park: Sound designer Gary Rydstrom combined several animal sounds to create the dinosaur voice: a mixture of tigers, lions, and alligators (for low-frequency roaring); a whale (for breathing); an elephant (for load roar); and a koala (for grunting).
The sound of opening door on Starship Enterprise: two sounds are combined: that of a piece of paper being pulled from an envelope and that of a squeaking shoe.
The voice and sound of Balrogs from Lord of the Rings: Sound designer David Farmer recorded a cinder block scraping along a wooden floor.
For further reading: Gaffers, Grips, and Best Boys by Eric Taub (1994)