Dialog editing and mixing is a complex subject.
It all starts with production sound, however. You do your best to eliminate extraneous background/ambient noise right at the outset. Then while shooting someone competent should be "swinging" the boom - that is, properly aiming the mic at the actors for optimum sound pick-up. This minimizes the problems with background noise and gives more consistency to the production dialog. When you are finished shooting the scene you then record several minutes of "room tone;" when outdoors you record several minutes of the ambient atmosphere.
Once the visual edit is completed you do the dialog edit, beginning with the dialog from the initial edit. What is done by professional dialog editors in the new digital day and age is to "checkerboard" all of the dialog - that is, organizing the dialog by character. So John goes on DX1 (Dialog Audio Track One), George on DX2, Mary on DX3, etc. The tracks are trimmed down to just the lines of dialog, all the "silence" (which is not really silent) between lines of dialog is stripped out (with unlimited track counts just put onto a track dedicated for the trimmings) and a track is created for Room Tone (RT) which will be used to fill in the "holes" between the lines of dialog.
The first chore is to look for obvious problem spots - a mumbled line, getting badly off-mic, a mic bump, etc. You use the dialog from the alt/unused takes to correct those problems. If you want to you can search for better line delivery. Those of us who do it for a living use Vocalign, which can conform a line from an alt take to the original take so that the substitution is visually seamless. Yes, sometimes it requires judicious editing (shortening a pause, lengthening a vowel, etc.) before you can use Vocalign. If you don't have Vocalign you will have to "manually" edit each word syllable by syllable to achieve the visually seamless match. If there are problems that cannot be fixed by using alt takes you will need to do ADR. These also occupy dedicated audio tracks (ADR1, ADR2, etc.) that match up with the DX tracks. (I always keep "leftovers" like the original dialog and the "trimmings" on muted/inactive tracks for reference.)
During the mix you first do noise reduction (this is usually done during "predubs"). iZotope RX Pro2 is the current mid-budget favorite, and many of the major houses use it as well. You can also use EQ notch filters, high pass filters and low pass filters to do noise reduction. The next step is to use EQ on the individual lines of dialog so that they match each other tonally. From there you do volume leveling. Some of rerecording mixers put some light compression on the dialog to give it a little more "pop," and some put a limiter on the dialog buss (sub-mix/stem) as a safety against sudden transient volume spikes. Compression and limiting should be used minimally as they can bring up the noise floor substantially if used incorrectly.
Now that you're left with all of this empty space between lines of dialog you need to do Foley to replace footsteps, clothing, props handling, etc. and, of course, sound effects like doors, vehicles and the like.