The built-in functionality to do what you're looking for is, very likely, Active Directory.
I wrote a script that creates local users and groups based on the list on another computer but that's not actually replication-- that's just copying the names of the users and groups and group membership. Each machine has a unique machine SID and, therefore, each group and user will have a unique SID on each machine, irrespective of their names being identical.
There's also no native mechanism to handle password synchronization other than Active Directory. If a user's password is changed on one server the change won't be replicated to the other.
If you want the machines to have users and groups with the same SIDs and to have password replication then Active Directory is what you're looking for.