Both shows pretty much consisted of character actors who had bit roles in TV shows and movies.
Well, that's not true. As
Melakon pointed out, several LiS regulars were well-known and established actors even before the show -- Guy Williams had starred in
Zorro, June Lockhart in
Lassie, and Angela Cartwright in
Make Room for Daddy, while Billy Mumy was the most ubiquitous child actor in Hollywood at the time.
As for
Star Trek, William Shatner was a respected stage and screen actor that many at the time saw as potentially the next Olivier, and it was considered a major coup when this little-known producer named Roddenberry secured him as the lead of his weird, experimental outer-space show. He'd even had a previous starring role on television, in a courtroom drama called
For the People that ran for half a season in '65. Just before ST, he had a recurring role in the popular
Dr. Kildare. Leonard Nimoy hadn't had a starring role, but he was well-known as a character actor by that time, as was DeForest Kelley for his extensive work in Westerns including
Gunfight at the OK Corral.
I don't know how Smith and the Robot came into the picture, they weren't in the original pilot reel.
Smith was added because the producers, on reviewing the pilot, felt the premise lacked conflict and the series would need an antagonist. As for the Robot, apparently Allen just had the idea after the pilot was made and thought it would be a good addition.
Jonathan Harris' constant "Special Guest Star" billing in the main title, for the entire run, must have been orchestrated by a brilliant agent.
Not exactly. See, by the time Harris was brought in, all the other actors' contract terms, including their credits order, had already been negotiated and settled, so the only place left for him was last billing. But giving him lower billing than a couple of children was considered unacceptable, so the producers added the "Special Guest Star" credit to compensate. It was the beginning of what's now a common practice, treating last billing with a special notation as second only to lead billing in importance. (For example, see
Stargate SG-1. When Michael Shanks left the show for a season and then came back a year later, he was given last billing with extras added: "And Michael Shanks as Daniel Jackson." He had to go last since the other actors had been bumped up in the list, but the final place with "And" etc. counted as effectively second billing.)
Before Lost in Space ever arrived though, there was a Gold Key comic book around for a couple of years called Space Family Robinson. They were not the characters of the tv show, but there was a mom and dad and two kids. After the series appeared, some sort of arrangement was made, as the comic was rebranded as Space Family Robinson: LOST IN SPACE, though it still wasn't about the tv show.
It all started with
The Swiss Family Robinson, a 19th-century novel about a shipwrecked family (although that was probably inspired by
Robinson Crusoe originally). The novel has been the basis for multiple movies and TV series, including a film from Disney in 1960. A couple of years later, Disney began developing a science fiction remix of the concept called
Space Family Robinson, and had Gold Key develop a tie-in comic based on the film plans, but then the film fell through. Later, Irwin Allen decided to do his own take on
Swiss Family which he also planned to call
Space Family Robinson; it's unclear whether he was unaware of the comic or brazenly copying it. Anyway, CBS and Allen had to reach a legal agreement with the comics publishers, the upshot of which was that Allen changed the name of his show to
Lost in Space but got to keep the name Robinson for the family, while Gold Key got to add
Lost in Space to the title of their comic in order to capitalize on the show.
But eventually, in 1975, Allen produced a TV series version of
The Swiss Family Robinson for ABC. It starred Martin Milner, Willie Aames, Cameron Mitchell, and a 12-year-old Helen Hunt, and it lasted less than a full season. I think I remember watching it at the time, but only very vaguely.
I remember reading that when Gene Roddenberry was pitching Star Trek to CBS in 1964 or thereabouts, they weren't really interested in the show, they were just listening to him, looking for ideas for Lost in Space.
How true is this story?
Well, it's told in
The Making of Star Trek, largely from Roddenberry's own POV, which doesn't entirely answer the question of how true it was. But according to the account, they weren't looking for
story ideas per se -- that would've been plagiarism -- so much as ideas on things like spaceship design, how to handle the production and logistics of a space-based show, how to cut costs, etc.