If the external monitor shows a normal raster (video) with correct brightness, we can assume the GPU in your iMac is working OK. It also means your logic board is probably OK. That leaves us with the internal display of your iMac.
The symptom you describe may be a failing backlight (the CCFL which lights the screen) or it could be a defective inverter. Of the two, I would be more inclined to suspect the backlight. The inverter is a do it yourself replacement but does require care and skill. However, since replacing the backlight in the display, especially an iMac, is a daunting and difficult job, it's usually better to replace the entire display.
And there may be other reasons your display is not functioning correctly....
If your iMac is still under warranty, it would be best to have it looked at by Apple. If not, then you have a decision to make on how to go about repairing it.
Regards.