From the man page:
Specifies a program to be used for lookup of the user's public keys. The program will be invoked with its first argument the name of the user being authorized, and should produce on standard output AuthorizedKeys lines (see AUTHORIZED_KEYS in sshd(8)). By default (or when set to the empty string) there is no AuthorizedKeysCommand run. If the AuthorizedKeysCommand does not successfully authorize the user, authorization falls through to the AuthorizedKeysFile. Note that this option has an effect only with PubkeyAuthentication turned on.
The patch basically makes OpenSSH send the incoming user key to the script's stdin, and from the key it's trivial to match it against a user.
Here's a similar patch with the same purpose: https://github.com/norbauer/openssh-for-git
GitHub explained in "How We Made GitHub Fast"(2009) [1] they patched their ssh daemon, so that it would do some lookups in a MySQL DB.
I wonder if daemons like OpenSSH now have some kind of plugin mechanism that lets one use their own lookup strategy.
[1]: https://github.com/blog/530-how-we-made-github-fast