This is done for several reasons: Wrapper libraries can be implemented using the adapter, façade, and to a lesser extent, proxy design patterns.
The following provides a general illustration of a common wrapper library implementation.
The original C interface can be regarded as error prone, particularly in the case where users of the library forget to unlock an already locked mutex.
The new interface effectively utilizes resource acquisition is initialization (RAII) in the new Mutex and Lock classes to ensure Mutexs are eventually unlocked and pthread_mutex_t objects are automatically released.
In order to achieve this, languages like Java provide a mechanism called foreign function interface that makes this possible.