HTTP ERROR 500 comes on using theme function
In D8 controllers return a render array. Put the template name you have defined in hook_theme() in #theme. Prefix the variable names with a '#':

return array(
      '#theme' =&gt; 'my_module',
      '#my_module_header_message' =&gt; $my_module_header_message,
      '#my_module_form' =&gt; $my_module_form,
      '#my_module_footer_message' =&gt; $my_module_footer_message,
);