Your mistake is that after variable substitution bash does not handle quoted strings, i.e. it does not remove single quotes from sed command line. If you really need this to happen, you have to use eval:
i1xmr=$(echo "$i1p/$apiresponse*1000" | bc -l | eval $rmdec)
However using functions is a better solution in general. But in this particular case, I guess, you only need to change the bc's scale instead of using sed:
i1xmr=$(echo "scale=17; $i1p/$apiresponse*1000" | bc -l)
For better readability you may use heredoc instead of echo:
i1xmr=$( bc -l << EOF
scale=17
$i1p/$apiresponse*1000
EOF
)
Again, you don't need sed for this, simply set scale=2 or how many digits after decimal point you need. Also you missed ! in the shebang (#!/bin/bash or #!/bin/sh).
So I need five digits after the decimal point, but then when I do the multiplication, I only want four digits in total. I did move "scale=" to five and that made the sed command in rmdec much shorter, but its still needed. I thought i could add "length=4" but that throws an error.
Alright, I modified it and formatted it. However, for whatever reason, the output HTML in /var/www/html/index.html does not keep the formatting and is all just left aligned as before. That's not really a problem, just more of a curiosity as to why it did not inherit the formatting of the input.