My guess would be a permissions problem on creating that temp directory. When it was working, that temp directory might have been previously existing. When it didn't work, the temp directory was not there and failed to be created. When you were commenting/uncommenting that rm command you were affecting the existance of the temp directory, but NOT for the current execution, ... for the NEXT execution. Can be confusing! Something along those lines anyway.
Did you get any error messages on stderr when running this script?
Also, for scripting I never like to assume that a command worked. From your code, you're assuming lots of stuff (mkdir worked, cd worked, etc.) Never assume, especially if you're running as root (I think you are since you're using the -d option for rm, and that is only available for root).
I'd recommend using fully qualified paths and checking for command success, e.g.,
Code:
mkdir -p /full/path/to/temp
cd /full/path/to/temp
if [ "$?" != "0" ]
then
echo "ERROR: cd failed!"
exit 1
fi
cp $1 /full/path/to/temp/doc.pdf
if [ ! -s /full/path/to/temp/doc.pdf ]
then
echo "ERROR: Non-existant or zero length input file!"
exit 1
fi
pdftohtml -c /full/path/to/temp/doc.pdf
if [ "$?" != "0" ]
then
echo "ERROR: pdftohtml failed!"
exit 1
fi
blah, blah, blah ... you get the picture