Display roles in profile?
Updated answer

Scrolling through the Drupal.org module library, I discovered Role expose. I have never used it, but it seems to do the trick as well:


  Role Expose -module gives site administrators ability to expose user
  their own user roles. Roles are listed on user profile page. Users may
  be granted an option to view own roles or all users roles.
  
  


Original answer

Looking at the render array, I feel you misunderstood a bit (unless you have configured a field on the user object where you already put a string of all his roles, but then you would not need the logic here)...

$user_profile['field_user_roles'] = array(
  '#entity_type' =&gt; 'custom',          // Nope, it is 'user'.
  '#bundle' =&gt; 'custom',               // Nope, it is 'user'.
  '#theme' =&gt; 'field',                 // Probably it is not a field, but a custom render element containing markup.
  '#field_type' =&gt; 'text',             // Probably not since it probably wasn't a field.
  '#title' =&gt; 'Roles',
  '#label_display' =&gt; 'above',
  '#field_name' =&gt; 'field_user_roles', // Probably not since it probably wasn't a field.
  '#markup' =&gt; '&lt;ul&gt;' . $roles . '&lt;/ul&gt;',
  '#weight' =&gt; 5,
);


I guess it works better if you remove some of the data (see below).

On a small side note, logic should be avoided as much as possible within template files. So I'd recommend creating a small custom module and implementing hook_user_view_alter(). (If you are planning on supporting only one theme, you can also place it in the theme's template.php file. Use the theme name as the module name.)

function MODULENAME_user_view_alter(&amp;$build) {
  // Obtain the account that user_view() stored for us.
  $account = $build['#account'];

  // Prepare roles string.
  $roles = '';
  foreach ($account-&gt;roles as $rid =&gt; $role) {
    $roles .= "&lt;li&gt;".$role."&lt;/li&gt;";
  }

  if (count($roles) &gt; 0) {
    $build['modulename_user_roles'] = array( // Prefix with module name to prevent collisions.
      '#type' =&gt; 'item',
      '#title' =&gt; 'Roles',
      '#markup' =&gt; '&lt;ul&gt;' . $roles . '&lt;/ul&gt;',
      '#attributes' =&gt; array('class' =&gt; 'class-one class-two'),
    );
  }
}


Additionally you can implement hook_field_extra_fields() to expose the property on example.com/admin/config/people/accounts/display and choose its weight within the admin interface.

function MODULENAME_field_extra_fields() {
  $extra['user']['user'] = array(
    'display' =&gt; array(
      'modulename_user_roles' =&gt; array( // Make sure the name matches your custom property
        'label' =&gt; t('User roles'),
        'description' =&gt; t("Lists the user's roles."),
        'weight' =&gt; 5,
      ),
    )
  );

  return $extra;
}


Combined, the property should have been added to the $user_profile array and there is no more need to override the template file.

If you want to use the item_list, as proposed by Yogesh, your render array in MODULENAME_user_view_alter() should look something like this:

    $build['modulename_user_roles'] = array(
      '#title' =&gt; 'Roles',
      '#theme' =&gt; 'item_list',
      '#items' =&gt; $account-&gt;roles,
      '#type' =&gt; 'ul',
      '#attributes' =&gt; array('class' =&gt; 'class-one class-two'),
    );