Pitched for the show’s third season by “The Trouble with Tribbles” scribe David Gerrold, the premise was that an annoying, practical-joking, non-human alien joins the Enterprise crew on an adventure and seeks to test their mettle. BEM (a play on the acronym for Bug-Eyed Monster) is a colony creature with parts which can detach and act independently.
In fact, Gerrold provided concept drawings for how the creature might look and a costume might be built. After a very different and very plot-thin outline was submitted, Roddenberry suggested pairing Gerrold with "a good practical TV writer" to see if they could make it work as a script. But third season producer Frieberger chose not to, cutting it off after Gerrold turned in a revised story outline that was equally paper-thin.
(A few years later Gerrold dusted off this concept for the animated version of Star Trek, but that episode is a lot different than what Gerrold pitched back in 1968, especially after Roddenberry inserted a godlike alien entity into the proceedings. Interestingly, the animated show ought to have been able to portray BEM even more alien in appearance than Gerrold suggested, but he ended up looking blandly anthropomorphic.)