Precise measurements of the spin structure functions of the proton $g_1^p(x,Q^2)$ and deuteron $g_1^d(x,Q^2)$ are presented over the kinematic range $0.0041 leq x leq 0.9$ and $0.18 $ GeV$^2$ $leq Q^2 leq 20$ GeV$^2$. The data were collected at the HERMES experiment at DESY, in deep-inelastic scattering of 27.6 GeV longitudinally polarized positrons off longitudinally polarized hydrogen and deuterium gas targets internal to the HERA storage ring. The neutron spin structure function $g_1^n$ is extracted by combining proton and deuteron data. The integrals of $g_1^{p,d}$ at $Q^2=5$ GeV$^2$ are evaluated over the measured $x$ range. Neglecting any possible contribution to the $g_1^d$ integral from the region $x leq 0.021$, a value of $0.330 pm 0.011mathrm{(theo.)}pm0.025mathrm{(exp.)}pm 0.028$(evol.) is obtained for the flavor-singlet axial charge $a_0$ in a leading-twist NNLO analysis.