Circadian rhythms are oscillations in biological processes that function as a key adaptation to the daily rhythms of most environments. In the model cyanobacterial circadian clock system, the core oscillator proteins are encoded by the gene cluster kaiABC. Genes with high expression and functional importance, such as the kai genes, are usually encoded by optimal codons, yet the codon-usage bias of the kaiBC genes is not optimized for translational efficiency. We discovered a relationship between codon usage and a general property of circadian rhythms called conditionality; namely, that endogenous rhythmicity is robustly expressed under some environmental conditions but not others. Despite the generality of circadian conditionality, however, its molecular basis is unknown for any system. Here we show that in the cyanobacterium Synechococcus elongate, non-optimal codon usage was selected as a post-transcriptional mechanism to switch between circadian and non-circadian regulation of gene expression as an adaptive response to environmental conditions. When the kaiBC sequence was experimentally optimized to enhance expression of the KaiB and KaiC proteins, intrinsic rhythmicity was enhanced at cool temperatures that are experienced by this organism in its natural habitat. However, fitness at those temperatures was highest in cells in which the endogenous rhythms were suppressed at cool temperatures as compared with cells exhibiting high-amplitude rhythmicity. These results indicate natural selection against circadian systems in cyanobacteria that are intrinsically robust at cool temperatures. Modulation of circadian amplitude is therefore crucial to its adaptive significance. Moreover, these results show the direct effects of codon usage on a complex phenotype and organismal fitness. Our work also challenges the long-standing view of directional selection towards optimal codons, and provides a key example of natural selection against optimal codons to achieve adaptive responses to environmental changes.