Context. The amount of data collected by spectrometers from radio to ultraviolet (UV) wavelengths opens a new era where the statistical and chemical information contained in the observations can be used concomitantly to investigate the thermodynamical state and the evolution of the interstellar medium (ISM). Aims. In this paper, we study the statistical properties of the HI-to-H2 transition observed in absorption in the local diffuse and multiphase ISM. Our goal is to identify the physical processes that control the probability of occurrence of any line of sight and the origins of the variations of the integrated molecular fraction from one line of sight to another. Methods. The turbulent diffuse ISM is modeled using the RAMSES code, which includes detailed treatments of the magnetohydrodynamics, the thermal evolution of the gas, and the chemistry of H2. The impacts of the UV radiation field, the mean density, the turbulent forcing, the integral scale, the magnetic field, and the gravity on the molecular content of the gas are explored through a parametric study that covers a wide range of physical conditions. The statistics of the HI-to-H2 transition are interpreted through analytical prescriptions and compared with the observations using a modified and robust version of the Kolmogorov-Smirnov test. Results. The analysis of the observed background sources shows that the lengths of the lines of sight follow a flat distribution in logarithmic scale from ~100 pc to ~3 kpc. Without taking into account any variation of the parameters along a line of sight or from one line of sight to another, the results of one simulation, convolved with the distribution of distances of the observational sample, are able to simultaneously explain the position, the width, the dispersion, and most of the statistical properties of the HI-to-H2 transition observed in the local ISM. The tightest agreement is obtained for a neutral diffuse gas modeled over ~200 pc, with a mean density n̅H̅ = 1−2 cm−3, illuminated by the standard interstellar UV radiation field, and stirred up by a large-scale compressive turbulent forcing. Within this configuration, the 2D probability histogram of the column densities of H and H2, poetically called the kingfisher diagram, is remarkably stable and is almost unaltered by gravity, the strength of the turbulent forcing, the resolution of the simulation, or the strength of the magnetic field Bx, as long as Bx < 4 μG. The weak effect of the resolution and our analytical prescription suggest that the column densities of HI are likely built up in large-scale warm neutral medium and cold neutral medium (CNM) structures correlated in density over ~20 pc and ~10 pc, respectively, while those of H2 are built up in CNM structures between ~3 and ~10 pc. Conclusions. Combining the chemical and statistical information contained in the observations of HI and H2 sheds new light on the study of the diffuse matter. Applying this new tool to several atomic and molecular species is a promising perspective to understanding the effects of turbulence, magnetic field, thermal instability, and gravity on the formation and evolution of molecular clouds.