Newcommand with different definitions depending on the value of one argument

The following conditions on your choice of g, l and n for \geq, \leq and \neq. If you supply an empty mandatory argument (or nothing is matched), the result is =.

enter image description here

\documentclass{article}

\usepackage{xparse}

\ExplSyntaxOn
\DeclareDocumentCommand \hnull { o m } {%
  \tl_set:Nx \l_tmpa_tl {
    \str_case:nnF { #2 }
      {
        { g } { \geq }
        { l } { \leq }
        { n } { \neq }
      }
      { = }
  }
  \IfValueTF {#1} {
    H \c_math_subscript_token 0:\:\mu \l_tmpa_tl #1
  }{
    H \c_math_subscript_token 0:\:\mu \l_tmpa_tl \mu \c_math_subscript_token 0
  }
}
\ExplSyntaxOff

\begin{document}

$\hnull[55]{l}$

$\hnull{g}$

$\hnull{n}$

$\hnull{l}$

$\hnull{}$

\end{document}

It's quite simple with no check for the first argument:

\documentclass[a4paper,11pt]{book}
\usepackage{amsmath}
\usepackage{xparse}

\NewDocumentCommand{\hnull}{ O{\mu_0} m }
 {%
  H_0:\mu\hnullsymbol{#2}#1%
 }

\ExplSyntaxOn
\NewDocumentCommand{\hnullsymbol}{m}
 {
  \str_case:nnF { #1 }
   {
    {g}{\geq}
    {l}{\leq}
    {n}{\neq}
   }
   { #1 }
 }
\ExplSyntaxOff

\begin{document}

\begin{gather*}
\hnull[55]{l} \\
\hnull{g} \\
\hnull{n} \\
\hnull[33]{=} \\
\hnull{<}
\end{gather*}

\end{document}

The \mathlarger serves no purpose and the additional spacings you have only make the thing less readable, in my opinion.

enter image description here