The Andante favori was written between 1803 and 1804, and published in 1805. It was originally intended to be the second of the three movements of Beethoven's "Waldstein" piano sonata, Opus 53. The following extract from Thayer's Beethoven biography explains the change
Ries reports (Notizen, p.101) that a friend of Beethoven's said to him that the sonata was too long, for which he was terribly taken to task by the composer. But after quiet reflection Beethoven was convinced of the correctness of the criticism. The andante ... was therefore excluded and in its place supplied the interesting Introduction to the rondo which it now has. A year after the publication of the sonata, the andante also appeared separately.
Many listeners today would agree that Beethoven's decision was a good one--the slow introduction that replaced the andante tightened the sonata and made it more dramatic, while the Andante favori stands well as a work on its own.
The reason for the title was given by Beethoven's pupil Czerny, quoted in Thayer: "Because of its popularity (for Beethoven played it frequently in society) he gave it the title Andante favori ("favored Andante").