That's a very long story, but here's the short version.
John Mitchell of Screen Gems (distributor for Hanna-Barbera Productions)
suggested a prime-time animated series, which had never been attempted
before. William Hanna and Joseph Barbera experimented with different sorts
of cartoon families before storyboard illustrator Dan Gordon hit on the idea
of cavemen and their "modern stone-age" appliances. (Other accounts credit
either Harvey Eisenberg or Milt Rosen with the original idea. Bill Hanna
maintains that Gordon's was the true inspiration.) Gordon's sketches were
forwarded to Ed Benedict, who refined them into the characters of Fred,
Wilma, Barney, and Betty. (Benedict based his characters at least in part
on cavemen he designed for the 1955 Tex Avery MGM cartoon, "The First Bad
Man.")
Plot outlines (by Barbera and Gordon) and storyboards (by Gordon) were drawn
up for the first two episodes, and Barbera spent an exhausting two months
pitching the show before it was finally purchased by ABC in March 1960.
Equally nerve-wracking pitches were required before R. J. Reynolds (the
cigarette company) and Miles Laboratory (the makers of Flintstones Vitamins)
agreed to sponsor the program.
More problems arose as the pilot deadline approached and it seemed that The
Flagstones (as it was then still called) would not be ready. The Screen
Gems people, however, decided they liked what they saw and gave H-B a bit
more time. A last-minute name change, and the rest is (pre)history.