You can wrap the string in [code] tags and use the bb_code() function:
HTML:
{{ bb_code("[code]<span>this is code<b>should show with the html tags</b></span>[/code]", null, null) }}
Or you can escape the HTML when setting the variable using the escape filter:
HTML:
<xf:include template="bb_code_tag_code">
<xf:set var="$content">{{ "<span>this is code<b>should show with the html tags</b></span>"|escape }}</xf:set>
</xf:include>
Or if you use the self-closing form of <xf:set>, the value will be escaped automatically: