Engages in vigorous handwaving and holds nose whilst diving into the treknology kiddie pool
Well, I can think of a couple of reasons you would do this.
- Emphasize the serious nature of the situation for the crew (not too likely)
- Shut down nonessential systems to conserve power (for stuff like, say, the shields) and simplify power management (likely)
- Shut down systems which might cause hazards if damaged while operating (there's enough arcing power and Magic Smoke 'N' Sparx from the critical stuff like the helm console!)
- Improve low light vision (the real reason wet-navy ships do it) so that in case of having to perform damage control with no lights you don't need to acclimate (possible)
- Make consoles and other critical visual aids more visible from a distance (possible)
Since (especially when Riker is commanding) we end up on battery power after the Red Alert anyhow (since the cause of the alert has likely tuned to the shield frequency and proceeded to whup-ass all over the Big E and maybe even muss Riker's hairspray) then why not just lower the power demand now? :-)
In response to xunker's addendum:
Oh, well, if you put it like that, then I can tell you the real reason.
See, the crew of the Enterprise are (not surprisingly) geeks. Therefore they work better at night, need caffeine, and are sensitive to surrounding bogon particle levels.
Dangerous situations is when you want your crew at maximum performance.
The Enterprise contains a Bogon Interdeck Filtration and Forwarding System (BIFFS) which serves to maximize crew performance for short periods of time by removing the zener particles known as bogons from the Big E's atmosphere. This creates an artificial, corresponding high percentage of clueons in the ship's interior. The bogons are then stored temporarily in a Quantum Interferometric Zener Retention Ovosphere (QUIZRO). However, the operation of BIFFS takes an enormous amount of power.
Therefore, since the crew operates better at 'night' anyhow, the lights are dimmed and the power saved is then sent to run BIFFS and also power the replicators to produce the enormous quantities of Red Bull and Jolt that will be demanded of them when yawning, groggy, naughty-bit-scratching crew members reach their duty stations. See, since caffeine is such a high-energy substance, you need to put a lot of energy into the replicators to make it. Handily, geeks and Starfleet personnel work better at night, so you have all this extra power.
Of course, the Laws of Quantum Bogodynamics mean that this unbalanced zener distribution can only be maintained for a short while. Not only will the ship's systems drain available power due to higher demand, but bogon storage accumulators become dangerously full and require emptying in order to prevent Catastrophic High-order Asininity Overload Syndrome (CHAOS) from affecting the crew as the stored bogons spread violently and uncontrollably back through the ship. Now, normally, the system is set to dump all the stored bogons out of the QUIZRO, at the end of the alert, into a Designated Internal Personnel Storage for High Intensity Transfer unit (DIPSHIT). The particles are then allowed to escape slowly back into their environment by emanating from the DIPSHIT in question (The Big E has two redundant assigned units, Ens. Wesley Crusher and LCdr. William Riker).
In cases of severe emergency, eXtra Unit Neutronium Kilo-Erg Retainers (XUNKERs) can be activated to augment BIFFS, but this takes more available power. The danger here is that these units are somewhat unstable, and may fail unexpectedly due to Tertiary High-Energy Flux Emission of Zeners (THEFEZ). THEFEZ arriving on the scene always indicates definite increases in localized incidents of CHAOS in the Designated Energy Management, BOgoN Extraction Systems computer (DEMBONES).
Now, there are a few prescription Starfleet responses to such THEFEZ CHAOS in DEMBONES. One early-warning system, the Non-Axial Twin Emitter (NATE) can be deployed to try to either reduce THEFEZ CHAOS inputs, stabilize DEMBONES, or even (in cases of extreme emergency) perform a Wide-ORDer (Galaxy Class) Generator sweep (Word galaxy Generator procedure) which may restore equilibrium to the stressed systems at the cost of agitated NODERS (Neutronium Omni-Directional Echo Resonators). These typically require a cooling-off period before the Word galaxy generator can be activated again.
So, as you can see, the problem of power, zener particle management, caffeine production and distribution, THEFEZ CHAOS in DEMBONES requiring NATE's WORD GALAXY GENERATOR as well as the more mundane problems listed above all contribute to the darkening of the Big E's lights during an alert.