The "vertical stabilizer" (or "vertical fin") provides what is known as "weathervane stability", "directional stability", or "yaw stability". It makes the plane act like a weathervane. A weathervane always points into the wind.
The wind a plane "feels" is not the external, meteorological wind, but rather the "wind" created by the plane's movement through the airmass (or perhaps we might prefer to say "within" the airmass). This apparent wind is called the "relative wind". So the vertical fin keeps the nose of the plane pointing in the direction that the plane is actually going, i.e. in the direction that the plane is moving through the air.
Imagine driving a car at high speed on an icy lake on a day with no wind. Can you see how a big vertical fin mounted at the back of the car would provide a "weathervane effect" that would tend to keep the car lined up with the direction it is actually moving, and would tend to prevent the car from "swapping ends" or sliding sideways?
That is what the vertical fin on an airplane does. It's a very bad thing if an aircraft "swaps ends" or slides sideways through the air at a very large sideslip angle. In extreme cases, there's essentially nothing the pilot can do to salvage the situation, and the plane may tumble violently out of control. It's a misconception to say that the function of the vertical fin or vertical stabilizer could be replaced by appropriate control inputs with the ailerons. It is true in many cases that planes with relatively small vertical fins often require the pilot to make larger rudder inputs to keep turns "coordinated", i.e. to keep the nose from swinging somewhat out of line with the direction the plane is going as it turns -- we'll save saying any more about that for some other answer.
Airplanes that lack a vertical fin must derive "weathervane stability" or "yaw stability" or "directional stability" from other aspects of the aircraft's configuration, generally having to do with the fact that more surface area is behind the center of gravity than in front of it. For example, a swept-wing configuration generates some amount of "weathervane stability" even without a vertical fin. Imagine putting a pair of swept wings or delta wings on a pole like a weathervane. Can you see how, as long as the pivot point were sufficiently forward, the whole assembly would tend to point into the wind like a weathervane? That's why hang gliders don't need vertical fins.
The question appears to contain a misconception about the relationship between yaw stability and roll stability. In fact, making the vertical fin too large actually tends to make a plane LESS roll-stable or MORE spirally unstable, so that it tends to roll away from wings-level into a steeper and steeper bank and turn. As a plane starts to roll into a turn, dihedral and sweep (if either are present) tend to generate a stabilizing roll torque that tend to roll the plane back towards wings-level, but only if the developing turn involves some amount of sideslip. In other words the roll-stabilizing effect of sweep or dihedral are only present if the plane is sideslipping to at least some small degree. A large vertical fin tends to prevent sideslip, and thus makes the plane behave as if it had less dihedral or sweep. That's why planes that need lots of roll stability, like "free-flight" model airplanes that must fly with no guidance of any kind from either a pilot or a computer, rarely have large vertical fins. Even though we don't want the plane to completely "swap ends" and tumble, or to slide sideways through the air at a really extreme sideslip angle, we do need for there to be some amount of sideslip in an uncommanded bank and turn in order for sweep or dihedral to be able to bring the plane back toward wings-level. Likewise when a free-flight model airplane is trimmed for an intentional turn, if the sideslip were somehow completely eliminated, we'd see the bank angle start to get steeper and steeper. If a pilot were actively controlling the airplane, he could deal with this by making an appropriate control input with the ailerons, but that option doesn't exist with the free-flight model airplane.
So other than preventing a violent tumble when the plane "swaps ends" completely, a vertical fin generally doesn't really contribute to roll stability.