The dielectric function is one of the most important quantities that describes the electrical and optical properties of solids. Accurate modeling of the frequency-dependent dielectric function has great significance in the study of the long-range van der Waals (vdW) interaction for solids and adsorption. In this work, we calculate the frequency-dependent dielectric functions of semiconductors and insulators using the $GW$ method with and without exciton effects, as well as efficient semilocal density functional theory (DFT), and compare these calculations with a model frequency-dependent dielectric function. We find that for semiconductors with moderate band gaps, the model dielectric functions, $GW$ values, and DFT calculations all agree well with each other. However, for insulators with strong exciton effects, the model dielectric functions have a better agreement with accurate $GW$ values than the DFT calculations, particularly in high-frequency region. To understand this, we repeat the DFT calculations with scissors correction, by shifting DFT Kohn-Sham energy gap to match the experimental band gap. We find that scissors correction only moderately improves the DFT dielectric function in low-frequency region. Based on the dielectric functions calculated with different methods, we make a comparative study by applying these dielectric functions to calculate the vdW coefficients ($C_3$ and $C_5$) for adsorption of rare-gas atoms on a variety of surfaces. We find that the vdW coefficients obtained with the nearly-free electron gas-based model dielectric function agree quite well with those obtained from the $GW$ dielectric function, in particular for adsorption on semiconductors, leading to an overall error of less than 7% for $C_3$ and 5% for $C_5$. This demonstrates the reliability of the model dielectric function for the study of physisorption.