To start with, we can look at many different possible spacetimes, and it turns out that looking at certain algebraic varieties (or more generally, symplectic manifolds) is very fruitful. There are many reasons for this, but I'll mention just one: it turns out that the number of algebraic curves in these varieties is something which appears in physics.
Here is an attempt at explaining one piece of this (warning: I only understand the mathematical side, so what I say about physics may be completely wrong. If so, someone who actually knows physics please correct me. Also, note that I do not know how to explain this in a way that is not at least somewhat handwavy, though I will try to not say anything false.)
In classical mechanics, there is the Lagrangian formulation. What this says is that the path of an object must (at least locally) minimize a quantity called the "action" of the path. The calculus of variations lets us prove that this is equivalent to Newton's laws.
Now when you go to quantum mechanics (and in particular quantum field theory, which is where this is really useful), there is the Feynman path integral formulation: A particle may be treated as taking every path it could possibly take. However, most of these paths "cancel out" , and the only ones we actually end up seeing are the ones that are critical points of the action. What this means is that we can evaluate certain things in quantum field theory by integrating over all paths, as most of the paths will cancel out. (This "cancelling out" is something that can happen in quantum mechanics; to give an analogue, think of wave interference.)
Now if you we start working with strings, then as a string moves, we get a 2d-surface instead of a path, called the worldsheet of a string. As with the path integral, we now get integrals over these 2d-surfaces. It now turns out that the surfaces which don't cancel must be pseudoholomorphic curve, and when our spacetime is an algebraic variety, this pseudoholomorphic curve corresponds to an algebraic curve.
So counts of algebraic curves in complex varieties are something which appear in string theory.
Now of course there is no rigorous formulation of infinite-dimensional integration in mathematics. Therefore, many of the results obtainable via the Feynman path integral are not obtainable via traditional techniques, which is why mathematicians are interested in this relation.