The point isn't to fit the data sample. It's to try to model the underlying physical processes that led to your data sample, in a way that accomplishes some desired goal.
Trivially, the "best fit" to your data sample is a function defined only at the observed values of $x_i$, taking the corresponding observed value of $y_i$ at each $x_i$. I know that's not what you are looking for, but starting with such an extreme example can help clarify the issues involved. What you presumably want is some continuous function that could reasonably have produced your observed data sample.
As @whuber pointed out, you thus need to consider the nature of that underlying continuous function. If you have some reasonable physical model of the relationship between the $x_i$ and the $y_i$, depending perhaps on some parameter values that could be estimated from the data, then you can use that to start. Linear regression does this by assuming an underlying linear relationship; non-linear fitting is appropriate if the underlying physical reality suggests a fundamental non-linear relationship.
The phrase "machine learning" as used in one of your comments encompasses several approaches to discover potentially useful relationships from data. Note that many successful approaches that start with minimal assumptions about the functional form of the data, like boosted regression trees, do not return any simple function at all. They nevertheless can do quite well at capturing relationships within a data set. So, no, machine learning is not trying to solve an ill-posed problem: it attempts to learn relationships from a set of data (typically with many more than 10-20 data points) that can be useful for some particular purpose. Those relationships might or might not have simple functional forms of the type you seek.
If your interest is simply in a reasonably smooth curve that nicely interpolates ($x,y$) data without being too wiggly, then you could consider either loess (locally weighted regression) or splines. See this page and its links for example.
But how do you know that your data sample was actually taken from a process with a non-wiggly underlying physical process? This page shows the same 9 ($x,y$) data points fit with linear interpolation, a high-degree polynomial, and a restricted cubic spline. Although the restricted cubic spline looks nice and happens to match pretty closely the particular function from which these data points were sampled, what if the underlying function had actually been the polynomial? That's why the question is ill posed, absent specific criteria for what is meant by the "best fit."