How do I render user Login block in main menu?
Block content can either be a string or a render array. As such you need to run it through render:

$block_content = module_invoke('user', 'block_view', 'login')['content'];
return '&lt;ul class="menu nav navbar-nav"&gt;' . $variables['tree'] . render($block_content) . '&lt;/ul&gt;'; 


It's worth bearing in mind that the user login form isn't wrapped in &lt;li&gt; tags, so unless you're altering the markup for that form elsewhere, your code will produce invalid markup.