When did people discover that the Earth is not an ideal sphere, but a little flattened? And if you know, who was the first person to discover it?
It wasn't one person. René Descartes had theorized that planets must be in the shape of prolate spheroids. Christiaan Huygens and then Isaac Newton theorized that a rotating, self-gravitating fluid body would relax itself into an oblate spheroid. So which view was correct? Giovanni Cassini argued strongly that Descartes' view was the correct one, and he argued with measurements.
The French Academy of Sciences was split on this important question in the 1730s. The question was of interest in the world of commerce because knowing the shape of the Earth became of increasing import with regard to accurate ship navigation. To this end, the king of France financed two expeditions by the Academy, one to Peru and the other to Lapland.
The group that went to Lapland included Pierre Louis Maupertuis (the head of the Academy), Alexis Clairaut, Charles Camus, Anders Celsius, and others. This group left after but returned before the group that went to Peru. Their measurements agreed with the Newton's concept of an oblate spheroidal shape and disagreed with Descartes' concept of a prolate spheroidal shape. While their observations tilted the discussion in the favor of the Newtonian view, some of those who argued for a prolate spheroidal shape remained unconvinced. Jacques Cassini (Giovani's son) strongly disagreed, arguing that the measurements the group had made in Lapland were flawed. Cassini de Thury (Jacques' son) continued the family argument.
The group that went to Peru took ten years to return. (The voyage to Peru took over a year, all by itself.) The group was plagued by bad luck, lack of supplies, and inept and corrupt leadership. The leader of this expedition wanted no part in the diplomacy and management tasks required of an expedition leader. Even worse, he spent a good part of the expedition's funds on a hottie, and then bailed on the team entirely.
The reluctant second in charge, Pierre Bouguer, took over and made the expedition work. He and his team of over a dozen other scientists made astonishingly precise measurements of the distance between two Andean mountaintops. On returning, it was those measurements that convinced the remaining oblate spheroid skeptics that the Earth was indeed more or less an oblate spheroid.
And if you know, who was the first person to discover it?
From the above, it should be obvious that it wasn't one person. It most certainly was not Descartes or the Cassini family. (But all four are remembered for their positive contributions to mathematics and science.) But it's very hard to say who was the first to discover that the Earth is an oblate spheroid (more or less) is given that so many people contributed to this discovery.
This, by the way, is how modern science works. Most modern scientific discoveries are team efforts. In the case of physics at the Large Hadron Collider, the list of authors on key scientific articles takes an entire page. It's been argued that Newton was the first modern scientist. It's also arguable that he wasn't. He worked alone. The discovery of the figure of the Earth was very much a collaborative effort that spanned over half of a century.
W.W. Payne, "Attraction and figure of the Earth." Popular Astronomy 9 (1901): 117-123.
A rather old but very nice article on this old subject.
P. Lynch, "That’s Maths: Earth’s shape and spin won’t make you thin."
A lay article on the expedition to Lapland, which was led by Maupertuis.
D. Main, "The Remarkable Story of the First Accurate Measure of the Earth"
A lay article on the expedition to Peru, which was ultimately led by Bouguer.
The Wikipedia article on Clairaut's theorem
Clairaut was one of the key members of the expedition to Lapland. His equation that describes gravitational acceleration as a function of latitude was supplanted by a slightly better expression, the Somigliana equation, almost two hundred years later.
Wikipedia articles on Descartes, Huygens, Newton, the three Cassinis (three links), Maupertuis, Clairaut, and Bouguer.
Take these with the grain of salt one should always take when reading Wikipedia articles.
While it was suggested by other previously, I believe the first actual deduction of the shape by theory which resulted in a measurement was due to Pierre Louis Maupertuis.
It was Maupertuis who worked out the theory predicting Earth was an oblate spheroid and who also made measurements (on an expedition to Lapland) which confirmed this. His theoretical work was based on the (then quite new and not as accepted as they are now) theories of Newton about gravity and mechanics. It must be remembered that calculus was also a relativity recent development so this was cutting edge work in it's day.
It was probably in the mid-17th century, and may have ben Isaac Newton, as PM 2Ring suggests, or one of several other people. Galileo devoted a lot of time to studying Jupiter and Saturn, and if he had good eyesight would probably have noticed that both planets were oblate spheres. Christian Huygens a little later in the century also studied both planets and observed that they were oblate spheres. Both men were astute enough to realise what was the cause of this oblateness, and knew that because the Earth rotated fairly rapidly the same principles would apply to Earth. We will never know with certainty who first made this analogy between Earth and the two gas giants, but it must have been in the 17th century.
We will also never know who first mentioned in print that the Earth too was an oblate sphere; that information has also been lost in the mists of time. By the time it was first mentioned in print, a lot of people must have been aware that theory dictated that this must be the case and all that needed to be done was to measure what was already a foregone conclusion.