I was reading the following version of the Miller-Rabin algorithm:
it can also be found on page 6 of the following notes. The first if statement checks wether the input $n$ is a perfect power. i.e. wether $$n = b^a $$ is satisfied. My question is, why is that a special case that is checked at the beginning? If we didn't exclude numbers of that form, would the remaining of the algorithm not work? Why do we check that?

The algorithm cannot become wrong if you omit that check. After all its only outputs are "definitely composite" or "possibly prime" and neither of these outputs is wrong for a (necessarily composite) perfect power. Also, the general credibility of the test is based on the fact that repeated tests with independently random initial values $a$ are performed and one can show that at least $\frac34$ of the candidate $a$ do produce "composite" as output of $n$ is composite - no matter if it is a perfect power or not. In fact, perfect powers have unusually many divisors so are likely to be detected quickly anyway.
It seems that the text you reference adds the test only to simplify the proof that the witness probability is at least $\frac12$: At one point they need two nontrivial coprime factors of $n$ in order to apply the Chinese Remainder Theorem, and even for this it suffices that $n$ is not a perfect power of a prime.
Besides,