Drupal 8 function from controller returns html markups only
The error message is not pointing in the right direction. It should say:

"The controller must return a render array"

For example the most basic one:

return array(
  '#markup' =&gt; '&lt;p&gt;This is html markup&lt;/p&gt;',
);


The error message is from symfony, and from the stand point of symfony this is correct. A controller must provide a response, but drupal has extended the response handling to look for render arrays, that are then used the generate a response with the rendered html. If you don't provide a render array, then there is no response and then this error message will come up.