If you write a hit song, you're supposed to make a bunch of money, but as we all know by now, that isn't always the way it works — and the story of Richard Berry, who wrote "Louie Louie," is a perfect example of how a songwriter can end up stuck on the outside watching others make millions from his creation.

Berry started his recording career as a member of the L.A.-based doo-wop group the Flairs, and although they failed to gain any significant chart traction during his short stint in the lineup, he succeeded in catching the ears of producers Jerry Leiber and Mike Stoller, who utilized his (uncredited) bass voice in the Robins' "Riot in Cell Block #9" — a role he'd again fill for Etta James on her hit "The Wallflower (Dance With Me, Henry)." By 1954, Berry had embarked on a solo career with his band the Pharaohs while continuing to write and record for other artists.

It was during this period that Berry picked up a gig playing with the 12-piece band Rick Rillera and the Rhythm Rockers, sharing a bill that gave him regular exposure to the band's cover of René Touzet's "El Loco Cha Cha." Separated by the wall between the dressing room and the stage, he found himself bewitched by the rhythm that would eventually propel "Louie Louie."

"I was working with a Mexican-American band down in Anaheim, California," Berry recalled during a 1989 radio interview. "I used to work out there with them every Sunday night — they played a lot of Latin music, and I did the R&B part of their show. While sitting in the back of the dressing room waiting to go on, I'd listen to them, and the music really got to me. I said, 'I bet I could write something to some of this stuff.' 'Louie Louie' just popped out of the top of my head, and I wrote it on a piece of toilet paper."

While "El Loco Cha Cha" influence is immediately apparent from the opening notes of "Louie Louie," Berry didn't just copy Touzet's song; instead, he built on that riff, pulling parts from a multicultural grab bag of influences that included Nat King Cole's "Calypso Blues" and Johnny Mercer's "One for My Baby (And One More for the Road)," a classic tale of barfly woe whose lyrics helped shape the way Berry's protagonist in "Louie Louie" ends up telling his story to a bartender.

"There was an old Chuck Berry song called 'Havana Moon,'" continued Berry. "So what I did was mix some Latin with some calypso and some R&B, and I came up with 'Louie Louie,' which was actually the B-side of the record that I really thought was going to be a big seller for me, which was 'You Are My Sunshine.'"

"Sunshine" was a minor local hit, but "Louie Louie" more than doubled the single's shelf life when legendary Los Angeles disc jockey Hunter Hancock flipped the record. Although it never translated into major sales or airplay on a national level, the song quickly took on a life of its own among garage bands along the West Coast, including Seattle's Rockin' Roberts and the Wailers, who had their own regional hit with their version a few years later.

Roberts didn't really hit pay dirt with his version of "Louie Louie" either, but that recording was eventually heard by another band — the Kingsmen, from nearby Portland, Ore. — and they decided to cut their own cover, which was released on Aug. 8, 1963. The rest was rock 'n' roll history.

Unfortunately, by the time the Kingsmen's version of "Louie Louie" hit No. 2 on the pop charts — where it would stay for an impressive six weeks — Berry no longer had a claim to the publishing royalties. According to Celebrity Net Worth, he sold his stake in 1959, part of a transaction that sent many of his publishing rights to the Flip Records label in exchange for $750.

It seems like a paltry sum today, but at the time, it was a relatively significant payday, especially for a performer whose multiple attempts to achieve hitmaker status had largely come to naught. Berry didn't have any reason to believe his catalog would ever turn him a profit and he was planning a wedding, so he needed the cash — and for a little while, it probably seemed like he'd gotten the better end of the deal.

Listen to the Kingsmen's 'Louie Louie'

The Kingsmen's version, however, succeeded on a level that neither Berry nor anyone at his label could have guessed — partly because it boasted a raggedly lo-fi sound that was perfectly in step with the times, and partly because singer Jack Ely, hampered by braces and a microphone that had been set up so high he had to stand on his toes and shout over the band to be heard, delivered a lead vocal that left many listeners wondering just what exactly he was saying.

In time, the controversy over "Louie Louie" hit such a fever pitch that the FBI got involved, dispatching a team of officers to spend hours conducting interviews and listening to the song until they eventually decided it was "unintelligible at any speed." If you listen to Berry's version, it's easy to tell that it's just a simple (albeit distinctively delivered) story about a guy with girl problems, but at first, Berry didn't even know he'd been covered.

"I didn't hear the Kingsmen's version until about three months after it was out," he admitted. "Some people came to me who'd heard my version and said, 'Man, these white guys, they recorded your song and they messed it up! You can't even understand what they're saying!'"

That didn't stop "Louie Louie" from becoming one of the most enduring hits — and arguably the most widely recorded song — in rock history. It took on new life after being memorably featured in the hit 1978 comedy Animal House, and eventually became ubiquitous, appearing on scores of compilations and soundtracks.

But as his song's stature continued to grow, Berry endured a series of personal struggles; as Celebrity Net Worth's report puts it, "By the mid-'80s, he was living on welfare at his mother's house in South Central L.A., and had basically disappeared into obscurity." But just when things might have seemed like they were at their bleakest, a team of lawyers for the California Coolers brand of wine cooler made a discovery that would change his life completely.

Celebrity Net Worth notes that California Coolers, in an effort to secure the rights to "Louie Louie" for a major new ad campaign, realized Berry actually needed to sign off on the commercial — and after the company's legal team asked the Artists' Rights Society to track him down, an ARS investigation determined that he'd been illegally deprived of millions of dollars in back royalties.

A lucrative settlement followed, along with a late-period career renaissance for Berry that found him conducting interviews and performing at high-profile gigs for the first time in decades. During the years prior to his death in 1997 of heart failure at the age of 61, Berry played regularly — even reuniting with the Pharaohs in 1995 — and reclaimed his "Louie Louie" along the way. Check out a lengthy live performance of the song, featuring Berry with a band of ace session players that includes sax player Steve Douglas and guitarist Ry Cooder, below.

See the Top 100 Albums of the '60s

Rock and Roll Hall of Fame's Worst Snubs