What is a sway bar? A sway bar actually tends to keep the car from swaying (or more specifically, from leaning to one side or the other). That is what a sway bar does: counteract body lean. The sway bar applies force to the suspension on each side, upward on one side and downward on the other, that tends to withstand the leaning.
Every sway bar is a torsion spring — a piece of metal that resists twisting force. The sway bar is attached at each end, one end to one wheel and at the other end to the opposite wheel (both fronts or both rears) so that in order for the wheel on one side to be higher than that on the other, the bar has to twist. The sway bar resists that twist, therefore forcing the vehicle’s suspension to remain level.
For one thing, it can be uncomfortable, disconcerting, or even dangerous for a vehicle to possess too much body roll in turns. More subtly, uncontrolled body roll tends to cause the wheels’ alignment, and in particular their camber to change, reducing how well they can grip the road; limiting body roll also tends to keep camber of the wheels under control, meaning more constant grip for braking and turning.