Nitpick: it's actually in libarchive, pacman/makepkg doesn't really care about the format.
Out of curiosity: Why doesn't pacman just use HTTP's built-in compression? It could cache packages in gzipped form, but there's no reason to re-compress them over the wire.
Because mirrors aren't guaranteed to use HTTP gzip compression and also gzip compresses much worse than xz.