This is very popular myth, but it is not true: Ptolemy's epicycles are not Fourier analysis!
Fourier series can indeed approximate an arbitrary periodic function. And you can approximate an arbitrary motion of period $T$ by the series of epicycles. The first is just a circular motion of period $T$, the second is an epicycle with period $T/2$ and so on.
But apparent planetary motion is not periodic: it is sum of two motions with different periods: one is proper planet motion and another is Earth motion. So Ptolemy's epicycles account just for these two motions. It's not Fourier approximation.
However because planets move not uniformly by circles but by Kepler's laws, the simple model of epicycles would give a very rough approximation. Here Fourier approximation would help: you can add additional epicycle to account for that. But Ptolemy's system did not do that. Ptolemy is most famous for inventing the model of equant. In this system a planet (or actually a center of epicycle) is moving on circle but not with uniform speed, it's moving with uniform angular speed with respect to some imaginary point that lies off center.
But there is some grain of truth in this myth. People indeed used epicycles that you would get Fourier's analysis of planetary motion. But it was done not by Ptolemy, but by... Copernicus. We know Copernicus for inventing heliocentric system. Because of this system Copernicus did not need Ptolemy's epicycles. But this is only one part of Copernicus work. The part that Copernicus was most proud was that he abolished Ptolemy's equant, but introduced new epicycles instead. These new epicycles were exactly the ones that we would get from Fourier's analysis. They have period $T/2$ as you would expect. This system had the same order of error as Ptolemy's: Ptolemy equant system had error $\approx 1/2e^2$, and Copernicus epicycles had errors $\approx 3/2e^2$ where $e$ is eccentricity, but Copernicus system was a little bit simpler, because it was sum of two uniform circular motions.
So, to recup: Copernicus got rid of Ptolemy's epicycles (which are unrelated to Fourier's analysis), because he put Sun in the center of Universe. But introduced new epicycles (which are the first Fourier approximation) instead of Ptolemy's equant system (which had the same purpose: approximate unknown Kepler's motion).
BTW, another legend that usually goes with this myth says that people before Copernicus added more and more epicycles to Ptolemy's system to make it more accurate. This is not true. No one before Kepler made a more accurate system that Ptolemy's. Fourier's epicycles was indeed added by Copernicus, but not to improve accuracy, but to make it simpler. And it was just first approximation (if we consider uniform motion as zeroth approximation). There was no epicycles that correspond to second term in Fourier series.