A Theory of Nonparametric Covariance Function Estimation for Discretely Observed Data