Since fireflies are active at night, they need some way to find members of the opposite sex in the dark. The flashing of their abdomens provides this.
The male firefly makes a courtship flight a few feet above the ground, flashing its abdomen in a pattern unique to its species. The female watches from the ground, and when she spots the right pattern, she begins to flash her own abdomen. The male seems this, flies to the female, and they mate.
The phosphorescent light is due to a chemical reaction triggered by a nerve impulse.
From: Ever Wonder Why? by Douglas B. Smith