Oliver Goldsmith wrote it. It is in the seventh of his “Chinese Letters”, published in a London paper in 1760–61 and collected in 1762 as The Citizen of the World, which are written in the voice of an imaginary Chinese philosopher. An editor's note says the letter seems “little more than a rhapsody of sentences borrowed from Confucius”, which is how the line came to be credited to Confucius. No such sentence has been found in the Analects.
What it means
Everyone falls; what counts is getting up again. The line moves the measure of a person from never failing, which nobody manages, to recovering, which anyone can.
Where it comes from
Goldsmith's letters are written by Lien Chi Altangi, a fictional Chinese traveller in London, to a friend in Peking. In letter VII he consoles himself after his wife and daughter are taken captive and his son goes after them, and the letter is headed by an editor's note: “The Editor thinks proper to acquaint the reader, that the greatest part of the following letter seems to him to be little more than a rhapsody of sentences borrowed from Confucius, the Chinese philosopher.” The line comes in the course of the letter: “Our greatest glory is not in never falling, but in rising every time we fall.” Letter XXII has a second form: “True magnanimity consists not in never falling, but in rising every time we fall.”
Quote Investigator found the line credited to Goldsmith in 1806 and 1824, and to Confucius by 1831, in a London ladies' magazine. Later it was credited to Ralph Waldo Emerson and to the epigram-writer Christian Nestell Bovee. The football coach Vince Lombardi used it, and Nelson Mandela used a version at the White House in 1998, which is why it is sometimes credited to them too.