The OP asked how a VGA cable works, so I'll start with the wiring for a standard cable, which is a DE-15 15-pin connector (sort of like the DB-9 connector used for RS-232, but with an extra row):
H-SYNC and V-SYNC stand for horizontal and vertical sync. The rest are self-explanatory. H-SYNC and V-SYNC are digital (TTL) level signals, active low, and the color signals are analog, 0v (black) to 0.7v (full color).
As implied by the presence of the H-SYNC and V-SYNC, there is horizontal timing and vertical timing. This diagram shows the timing for 640x480 VGA, which was one of the original VGA formats.
The horizontal timing, shown at the top of the picture above, represents one line of the screen (e.g. 640 visible pixels of a 640x480 display). Between each line of pixel data, there is a horizontal blanking area where no video is shown (this originally was primarily used in TV's to allow the CRT trace to move back from the right side to the left side of the screen, ready for the next line).
The horizontal sync is used to start the timing of each line. It is not quite as wide as the blanking area. Just before the horizontal pulse, there is a delay called the front porch. And just following the horizontal pulse is another delay called the back porch.
Although 640 pixels are displayed, 800 pixels are actually needed per line: 96 for the horizontal sync, 48 for the back porch, 640 for the video, and 16 for the front porch.
As shown in the diagram, each line is 31.77 µs long. Diving this by 800 pixels results in 39.7 ns per pixel. This corresponds to a 25.1 MHz clock rate.
The lines are gathered into frames, shown at the bottom of the picture. Like the timing for each line, there is a vertical blanking interval at the beginning of each frame (this originally was primarily used in TV's to allow the CRT trace to move back from the bottom of the screen to the top, ready for the next frame). On some older CRT TV sets, it was possible to "roll" the picture down and actually see this interval as a black bar across the screen. Like the line timing, there is a front porch and back porch area in the timing.
Although 480 lines are displayed, 521 lines are actually needed per frame: 2 for the vertical sync, 29 for the back porch, 480 for the visible lines video, and 10 for the front porch.
As shown in the diagram, each frame is 16.784 ms long. This corresponds to a 59.5 Hz frame rate.