It's the million-dollar question: how did a guy with little directing experience and an ego the size of Enterprise end up directing Star Trek V: The Final Frontier?
It's quite a story.
Prior to Star Trek V, William Shatner's only directorial experience was with a handful of episodes of T.J. Hooker, a goofy cop show in which he also starred. Not exactly a stellar resume—especially when it's for the latest big-budget entry in one of the most popular franchises of all time. So how did it happen?
The previous two Star Trek films were directed by Leonard Nimoy, who also plays Spock in the series. Nimoy did an admirable job with both films, as Star Trek III was modestly successful and Star Trek IV exceptionally so. Shatner decided that anything Nimoy could do he could do better, and he nabbed the gig for himself.
He achieved this by invoking a clause written into both his and Nimoy's contracts stating that whatever one received, the other would, too. (Seriously.) So if Nimoy got a raise, so would Shatner, and vice versa. Cleverly, Shatner invoked this clause during Star Trek IV's filming to convince producers to award him the directing gig the next time around.
As much as you can criticize the final product, Shatner put his all into the film. He even wrote the film's initial scenario, though it changed greatly over the course of production. That being said, The Final Frontier was his first and last time directing a big-budget feature film, so take from that what you will.