You can think of it as a precursor to LDAP.
It was a way to provide centralized access to User/Groups/Password and hostnames information over the network. YP was a staple of most UNIX deployments for some time, before being replaced by LDAP and DNS.
You'll find some historical context here [1].
[1] https://en.wikipedia.org/wiki/Network_Information_Service