Context. In the solar spectrum, the Balmer series line He is a weak blend on the wing of Ca II H. Recent high-resolution He spectroheliograms reveal a reversed granulation pattern and in some cases, even unique structures. It is apparent that He could potentially be a useful diagnostic tool for the lower solar atmosphere.Aims. Our aim is to understand how He is formed in the quiet Sun. In particular, we consider the particular physical mechanism that sets its source function and extinction, how it is formed in different solar structures, and why it is sometimes observed in emission.Methods. We used a 3D radiative magnetohydrodynamic (MHD) simulation that accounts for non-equilibrium hydrogen ionization, run with the Bifrost code. To synthesize He and Ca II H spectra, we made use of the RH code, which was modified to take into account the non-equilibrium hydrogen ionization. To determine the dominant terms in the He source function, we adopted a multi-level description of the source function. Making use of the synthetic spectra and simulation, we studied the contribution function to the relative line absorption or emission and compared it with atmospheric quantities at different locations.Results. Our multi-level source function description suggests that the He source function is dominated by interlocking, with the dominant interlocking transition being through the ground level, populating the upper level of He via the Lyman series. This makes the He source function partly sensitive to temperature. The He extinction is set by Lyman-a. In some cases, this temperature dependence gives rise to He emission, indicating heating. The typical absorption profiles show reversed granulation and the He line core reflects mostly the Ca II H background radiation.Conclusions. Synthetic He spectra can reproduce quiet Sun observations quite well. High-resolution observations reveal that He is not just a weak absorption line. Regions with He in emission are especially interesting to detect small-scale heating events in the lower solar atmosphere, such as Ellerman bombs. Thus, He can be an important new diagnostic tool for studies of heating in the solar atmosphere, augmenting the diagnostic potential of Ca II H when observed simultaneously.