I am trying to execute the following command:
$ bash -c \"var=\'test\' && echo $var\"
and only an empty line is being printed. >
Double quotes expand variables, so your command is expanded to
bash -c "var='test' && echo"
if $var is empty when you run it. You can verify the behaviour with
$var
var=hey bash -c "var='test' && echo $var"
Switch the quotes:
bash -c 'var="test" && echo $var'