We have measured the flux of cosmic muons in the Laboratori Nazionali del Gran Sasso at 3800 m w.e. to be (3.432 ± 0.003)⋅ 10−4 m−2s−1 based on ten years of Borexino data acquired between May 2007 and May 2017. A seasonal modulation with a period of (366.3 ± 0.6) d and a relative amplitude of (1.36 ±0.04)% is observed. The phase is measured to be (181.7 ± 0.4) d, corresponding to a maximum at the 1st of July. Using data inferred from global atmospheric models, we show the muon flux to be positively correlated with the atmospheric temperature and measure the effective temperature coefficient αT = 0.90 ± 0.02. The origin of cosmic muons from pion and kaon decays in the atmosphere allows to interpret the effective temperature coefficient as an indirect measurement of the atmospheric kaon-to-pion production ratio rK/π = 0.11+0.11−0.07 for primary energies above 18 TeV. We find evidence for a long-term modulation of the muon flux with a period of ∼ 3000 d and a maximum in June 2012 that is not present in the atmospheric temperature data. A possible correlation between this modulation and the solar activity is investigated. The cosmogenic neutron production rate is found to show a seasonal modulation in phase with the cosmic muon flux but with an increased amplitude of (2.6 ± 0.4)%.