How can I add custom markup with a theme function?
To do this the drupal way, you should use a theme function:

function MY_MODULE_form($form, &amp;$form_state) {
  $form['MY_MODULE']['message'] = array(
    '#theme'    =&gt; 'mymodule_markup',
    '#var1'     =&gt; $var1,
    '#var2'     =&gt; $var2,
  );
  return $form;
}


Then implement hook_theme:

function MY_MODULE_theme() {
return array(
  'mymodule_markup' =&gt; array(
    'variables' =&gt; array('var1' =&gt; NULL, 'var2'=&gt;NULL),
  ),
);


}

Then implement your theme function

function theme_mymodule_markup($var1, $var2) {
    return 'some string';
}


You also could use a template to render your markup. That way themers can overwrite your markup without having to dig into your module files.