In this paper we describe the history of the LHCb experiment over the last three decades, and its remarkable successes and achievements. LHCb was conceived primarily as a b-physics experiment, dedicated to CP violation studies and measurements of very rare b decays, however the tremendous potential for c-physics was also clear. At first data taking, the versatility of the experiment as a general-purpose detector in the forward region also became evident, with measurements achievable such as electroweak physics, jets and new particle searches in open states. These were facilitated by the excellent capability of the detector to identify muons and to reconstruct decay vertices close to the primary pp interaction region. By the end of the LHC Run 2 in 2018, before the accelerator paused for its second long shut down, LHCb had measured the CKM quark mixing matrix elements and CP violation parameters to world-leading precision in the heavy-quark systems. The experiment had also measured many rare decays of b and c quark mesons and baryons to below their Standard Model expectations, some down to branching ratios of order 10-9. In addition, world knowledge of b and c spectroscopy had improved significantly through discoveries of many new resonances already anticipated in the quark model, and also adding new exotic four and five quark states.