How to make custom fieldset collapsed by default in Drupal 8
All collapsible fieldsets have been replaced with HTML5 details
  elements.


Fieldset and legand are very hard to style and its not recommended to use with Drupal 8 any more. Instead its replaced with more cross browser way, which is the HTML5 Details &amp; Summary tags.

'#type' =&gt; 'details'


https://www.drupal.org/node/1852020

Drupal 7

$form['advanced'] = array(
  '#type' =&gt; 'fieldset',
  '#title' =&gt; t('Advanced settings'),
  '#collapsible' =&gt; TRUE,
  '#collapsed' =&gt; FALSE,
  '#description' =&gt; t('Lorem ipsum.'),
);


Drupal 8

$form['advanced'] = array(
  '#type' =&gt; 'details',
  '#title' =&gt; t('Advanced settings'),
  '#description' =&gt; t('Lorem ipsum.'),
  '#open' =&gt; TRUE, // Controls the HTML5 'open' attribute. Defaults to FALSE.
);