The library cache is a component of the Shared Pool which itself is a component of the SGA.
The library cache was introduced because parsing, validating and checking privileges of SQL statements is expensive in terms of CPU cycles.
The cache stores the results of a parsed SQL statement so that (the same) SQL statement can be executed multiple times (without having to re-parse it).
In versions prior to 10g, using dbms_stats.gather_table_stats would invalidate a cursor (i. e. remove the associated data from the library cache and cause a hard parse for the purged statements.
This behavior can now be controlled with the paramter no_invalidate of the dbms_stats packages.