A Codec is the piece of software responsible for taking the data from the sensor and compressing it to a more manageable size to fit in the memory card.
Codec compression involves discarding the data that is less relevant. Most codecs take advantage of the fact that the human eye is much more sensitive to brightness than color so they discard color information, in a process called croma sub sampling.
Codecs tend to discard the details in low lit regions, so it is advisable to raise the exposure and make the original image brighter. Making it darker and adding contrast afterwards can be easily achieved with post processing software.