As jmh has answered, stars naturally form at large distances from each other. To add to the answer, what is the reason for this particular distance scale?
If we imagine a very large, homogeneous cloud of gas it will be unstable to gravitational collapse over the Jeans length scale $\lambda_J=c_s/\sqrt{G\rho}$ where $c_s$ is the speed of sound in the gas, $G$ the gravitational constant, and $\rho$ the density. For typical values this about a light-year, giving a sense of the distance scale.
But why are those values what they are? $G$ is a fundamental constant and since it is small we get long distances. The speed of sound depends on temperature and molecular mass; since molecules are very light it is high. Why are molecules light? This is because another fundamental constant, the ratio between proton and electron mass, is large. The density of gas in the universe is low, since the universe has a density close to the critical density (had it not been that, it would either have recollapsed or expanded so fast there would not have been many stars).
A universe where stars form much closer to each other than in ours needs to have strong gravity (making stars burn much hotter and be short lived, beside lots of gravitational interactions disrupting planetary orbits), have heavy molecules (making chemistry weird), or have a high density (likely collapsing rapidly). So it is likely that there would not be any life and observers there.
The question also asks why gravity does not pull them closer to each other. Note that if the cloud turns into stars with typical mass $M\approx \rho \lambda_J^3$ separated by distance $r\approx \lambda_J$ then the acceleration between them will be $a=GM/r^2=G\rho \lambda_J^3/\lambda_J^2=G\rho \lambda_J =\sqrt{G\rho}c_s$. So the accelerations will be very small, again for the same reasons as discussed above.
(Further, due to the ratio between the electromagnetic force strength and the gravitational force strength, objects like stars have equilibrium sizes that are small compared to $\lambda_J$, so they rarely collide with each other on this timescale. They just miss, and fly past. )