AR is the GNU Archiver. It is a program for managing groups of object files held together in a single file. It is part of the GNU Binutils project.
Wherever possible, AR is compatible with other archivers although it does also tend to support extra features of its own.
RANLIB is actually a cut down version of the ar program, that only performs one of its functions - creating an index for a library that speeds up access to the files inside it. This index can also be created by ar, but historically this used not to be the case. So a long time ago the ranlib program was created to build indexes, and then later on the functionality was copied into ar.