In the present paper we investigate the approximate analytical diagonalisation of the Hamiltonian of the quantum Rabi model written in the Coulomb gauge and taking into account the gauge invariance of the system. It is shown that the Hamiltonian of the model can be diagonalised with high accuracy on the basis of a unitary operator of the gauge transformation utilising a simple basis set of state vectors. It is essential that the obtained approximate expressions do not depend on the variational parameters and are valid within the whole range of the parameter values. The zeroth-order approximation and uniformly available approximation are derived for the eigenstates of the system, and their comparison with the results of the numerical simulation is elaborated. The second-order correction to the zeroth-order approximation is deduced and its contribution to the energy of the system is estimated. The obtained results could be useful for description of the evolution of the quantum Rabi model as well as for investigation of systems of two-level atoms in the resonant quantum field.