How to add "Agree to terms" checkbox in Drupal 8 form
Your code was D7 and what should a checkbox do with #size and #maxlength? :)

This answer presumes you have the Devel submodule Kint installed.

/**
 * Implements hook_form_alter().
 */
function THEME_form_alter(&amp;$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {

  ksm($form_id); // Remove when done.

  if ($form_id == 'MY_FORM_ID') {

    $form['tos'] = [
      '#type'          =&gt; 'checkbox',
      '#title'         =&gt; t('Terms and Conditions'),
      '#required'      =&gt; TRUE,
      '#default_value' =&gt; TRUE,
    ];
  }
}


Check out this Introduction to Form API.