They come up for example in classical algebraic geometry. To a compact Riemann surface $S$ of genus $g$ you can associate a $g$-dimensional complex torus $J(S) = \mathbb{C}^g/\Lambda$ called the Jacobian of $S$. There is a mapping from $S$ to $J(S)$ called the Abel-Jacobi map and a lot of the geometry of $S$ can be studied from this mapping and other related objects.
The Riemann theta function associated to $S$ is a holomorphic function defined on $\mathbb{C}^g$. When the genus is one, i.e. when $S$ is itself a torus, this reduces to the Jacobi theta function and the parameter $\tau$ in the definition is the dependence on $S$ (compact Riemann surfaces can be parametrized by points on the upper half-plane). Now, while this function is defined on $\mathbb{C}^g$, it is not defined on the Jacobian $\mathbb{C}^g/\Lambda$ because it is not fully periodic (there are no non-constant holomorphic functions on a compact complex manifold anyways). However, it is "almost-periodic" in the sense that it satisfes some functional equations like mentioned on the Wikipedia entry. In particular, the zero-set of the Riemann theta function is well defined as a subset of the quotient $\mathbb{C}^g/\Lambda$ because it has the good periods in $\mathbb{C}^g$, it is called the theta divisor. In some sense, the information contained in the data of $J(S)$ and of a theta divisor completely determines $S$ (this is Torelli's theorem). From this point of view, it is clear that theta functions contain a lot of information about geometry.
I'm sure there are a lot of other stories like that, in particular having to do with number theory. For example they can be used to count the number of ways you can represent a prime number as a sum of whole numbers squared. So yes, you are right to think that people didn't just start taking a strange, sudden interest in these functions out of the blue. They came up by themselves while people were studying different areas of mathematics, they are very mysterious!