Billy Preston had first met the Beatles in 1962, as a 16-year-old; Preston was playing organ on Little Richard's tour of Britain, and the Beatles' manager Brian Epstein had booked Little Richard to play in Liverpool. Little Richard's Liverpool show in October 1962 was supported by close to a dozen local bands, and - no surprise - he went onstage right after the Beatles (who at this point had released 'Love Me Do', and so were the biggest names in Liverpool because they actually had a record in the charts).
At the Beatles' next run at the Star Club in Hamburg, in November 1962, they found that Little Richard (along with Billy Preston on organ) was also there, and this is where they came to get to know Preston. According to Preston, quoted in Mark Lewisohn's Tune In:
Right from the start, I fell in love with the Beatles. I was probably their first American fan and friend. John was great – he was funny, he was so smart and clever. I admired him instantly for his wit and manner. You just knew he was special; genius, I suppose, stood out even then, and even to me, a very naive kid.
He took the time to teach me how to play the harmonica. I learned Love Me Do and reciprocated by making sure that he, George, Paul and Ringo ate. They didn’t get any meals from the promoter, but Richard – being the big American headliner – got steaks and chops and a fabulous spread nightly, so I made sure they [the Beatles] were well fed and watered.
George Harrison seems to have taken a special shine to Preston, in particular; he had invited Preston to play organ onstage with them in Hamburg, but Preston demurred, concerned of Little Richard's sensibilities. While in Hamburg, Preston recorded a single with Sounds Incorporated (Little Richard's backing band), called 'Go', which was used on a jukebox movie called Just For Fun. This seems to have incurred Little Richard's wrath, and Little Richard left Germany without him.
Unfortunately, there's surprisingly little discussion of Billy Preston's involvement on Let It Be and Abbey Road in the usual Beatle biographies, and Mark Lewisohn isn't getting to that point in the Beatles' story any time soon (Tune In only goes to the end of 1962).
Billy Preston played on the 1966 Ray Charles album, Cryin' Time (which featured the hit 'Let's Go Get Stoned'), and proceeded to play in Ray Charles' touring band until 1969. According to Preston in a 1974 interview, in 1969,
George Harrison wanted me to stop by Apple Records. I came over, and they were recording and filming Let It Be. We started reminiscing about the old days, and that's how 'Get Back' got started. They asked me to take solo.
Mark Lewisohn in The Complete Beatles Recording Sessions talks about Preston just happening to be present at Apple's headquarters on January 22, 1969, that the Beatles basically plucked him from the lobby to play on the record. But it's very likely Harrison's ulterior motive seems to have been that having Preston there reduced some of the disruptive bickering that the band had been indulging in through the rehearsals at Twickenham for the songs that would become Let It Be.
There is some talk (e.g., in Walter Everett's The Beatles As Musicians) that Billy Preston was in London playing with Ray Charles at Festival Hall, and that George Harrison had seen play and then invited him to the sessions (Harrison says as much in the Anthology book), but I think that some jumbled memories are in play here, because Ray Charles played at Festival Hall in London in September 1969, rather than in January. Instead, Billy Preston seems to have been in London for definite Career Reasons; on the 19th of January, three days before he started playing with the Beatles, he recorded a TV special for BBC Two that was broadcast on the 31st. He also appeared on Lulu's TV variety show on the 25th. After appearing on the Beatles' rooftop concert on the 30th, Preston was signed to Apple Records as a recording artist on the 31st (his subsequent 1969 album Encouraging Words was produced by George Harrison, featuring the song 'That's The Way God Planned It', a #11 single in the UK).
All in all, appearing at the Beatles rooftop concert and playing on songs on Let It Be, etc, seems to have been something of a brand synergy operation for Preston, who was effectively leveraging his connections and building up hype, in the aim of building a successful solo career after deciding to quit playing in Ray Charles' band. So it seems unlikely that he would have joined the Beatles at this point, even if they asked him.
All in all, Preston's involvement with the Beatles as a band member was fairly minimal - he spent a week playing with the band, pretty much, from the 22nd to the 30th of January, on the Let It Be sessions. After this, he played Hammond organ on 'I Want You (She's So Heavy)' on February 22nd (having gone back to the US and returned in the meantime). While 'I Want You' eventually became part of the Abbey Road album, the dividing line was unclear at this point, and on February 22nd, this was effectively a continuation of the Let It Be sessions. Preston then played keyboards on 'Something' in May, with several Beatles recording sessions in between where he was either not invited or unable to attend.
So I think Preston was basically always a guest and there was never any serious discussion of him joining the band and becoming the Fifth Beatle. Instead, his presence on the Let It Be sessions was effectively an audition for a contract as a solo artist on Apple Records (something that he was already fairly ready for, given he was already doing TV specials and the like).