The color fields Foreground Color and Background Color are used for various tools.
Both colors can be exchanged by clicking the small double arrow. By clicking the two mini color fields the foreground color is set to black and the background color is set to white.
The foreground color is used by most drawing tools like painting, flood fill and so on. The eraser tool uses the background color.