Why does the decode function of the segwit bech32 encoder/decoder take a hrp (human readable part) as input?
The HRP is part of the bech32 encoded string, and in the bech32 decoding API, it is returned along with the payload by the decoder, after checking the checksum.

We still want to compare it with the expected HRP in BIP173, which encodes the chain the software is operating on.

Otherwise you could have a testnet node that accepts mainnet BIP173 addresses or the other way around.