A low level UUID (universally unique identifier) API was added in core (in #1252486: Low level UUID API in core) and later updated to be a service on the container in #1969572: Make Uuid a service. UUIDs are useful to be able to identify pieces of content and configuration for deployment and syncing. Drupal previously only supported increasing numeric identifiers, however when sites are cloned for development to a different environment, content and configuration may be created in both environments and the numeric identifiers may clash. UUIDs are a prerequisite to systems capable of merging the changes properly in deployment. While Drupal core provides universally unique identifiers for content and configuration, it will not provide deployment/environment merging capability entirely for all pieces of a site in core in Drupal 8.0.
To get a UUID, get the UUID service and use it to generate the identifier.
$uuid_service = \Drupal::service('uuid');
$uuid = $uuid_service->generate();
If you are using the core entity API (for configuration and/or content entities), you don't need to think about UUID generation, the created entities will get UUIDs automatically in the entity system. See https://drupal.org/node/1721572 and https://drupal.org/node/1818734 for examples.