The causal link between detrimental behaviors and cognitive performance remains unclear. This research seeks to investigate the causal impact of adjustable lifestyle factors on cognitive deterioration, including frequency of alcohol intake, onset of smoking, and sedentary activities like prolonged television viewing. This research combines large-scale genetic data obtained from univariable and multivariable Mendelian randomization analyses with experimental findings obtained from animal models. Our findings reveal that the odds ratio (OR) for cognitive function deterioration was 0.445 (inverse variance weighted [IVW] 95% CI: 0.370 to 0.536, p < 0.001) for each standard deviation increase in television watching time. After adjustment for body mass index (BMI), number of days walked /moderate activity over 10+ min and education in Multivariable Mendelian Randomization (MVMR), only the genetic predisposition to increased television watching time remained significantly associated with worse cognitive function (OR 0.659, 95% CI: 0.452 to 0.960, p = 0.030). The other two habits had no significant effects. Sensitivity analyses have confirmed that genetic pleiotropy did not influence the results. To further explore the relationship between sedentary behavior and cognitive function, as well as the underlying mechanisms, we conducted a restricted cage housing experiment and a physical exercise training experiment in mice. The results showed that physical exercise significantly improved spatial memory, as assessed by the Morris water maze, and increased exploratory interest, as evaluated by the open field test (OFT) and the elevated plus-maze test, compared to the sedentary control group. These cognitive advantages may be mediated through mechanisms involving free radical scavenging and enhanced synaptic plasticity. Our research provides genetic evidence indicating that extended television viewing is linked to an elevated risk of cognitive decline. Additionally, experimental data from mouse models suggest that physical exercise can counteract cognitive decline and anxiety-like behaviors induced by sedentary behavior. This protective effect is likely mediated by reactive oxygen species (ROS)-dependent mechanisms that enhance synaptic plasticity within the hippocampus.