Q:

Why do so many godlike beings show up in TOS? 

For maybe the first time, I'm more interested in a real-world answer.  In-universe, all that can really be said is that those "godlike" beings do exist, and Kirk and company crossed paths with them quite often. 
Out of universe, was this a favorite "angle" of Gene Roddenberry and the other writers?  Godlike beings in TOS seem to appear every other episode (Apollo, Melkotians, Trelane, Metrons, Organians, Guardian of Forever, "Shore Leave" aliens, Gary Mitchell, Thasians and Charlie Evans, Excalbians, Companion, Redjac, etc.,  etc.). 

A:

Most likely it was indeed.   It seems that Roddenberry took a dim view of most theistic beliefs, much as quite a few other humanists have done.   Here is a select quote attributed to Gene Roddenberry — culled from the Wikiquote page, I must admit. 

I think I’ve gone through quite an ordinary series of steps in life.  I began as most children began, with God and Santa Claus and the tooth fairy and the Easter Bunny all being about the same thing.  Then I went through the things that I think sensitive people go through, wrestling with the thoughts of Jesus—did he shit?  Did he screw?  I began to dare to believe that God wasn’t some white beard.  I began to look upon the miseries of the human race and to think God was not as simple as my mother said.  As nearly as I can concentrate on the question today, I believe I am God; certainly you are, I think we intelligent beings on this planet are all a piece of God, are becoming God.  In some sort of cyclical non-time thing we have to become God, so that we can end up creating ourselves, so that we can be in the first place. ...  My own feeling is that relation to God as a person is a petty, superstitious approach to the All, the infinite. 

As quoted in God & (1975) by Terrance A. Sweeney

So far as Roddenberry's personal beliefs, whether described as atheism or pantheism, were concerned, that quote really exemplifies, I think, the characteristics we see with all the gods and god-like beings featured in the episodes of Star Trek.   It appears to me that the idea was to portray that being seen as a god, or god-like, does not necessitate such an entity genuinely be omnipotent, omniscient, or perfectly wise, et al.