Why is to_char left padding with spaces?
You can see that in a simpler test case here

SELECT '&gt;' || to_char(1, '0') || '&lt;';
 ?column? 
----------
 &gt; 1&lt;
(1 row)


This is because, as @Abelisto said, the space is reserved for the sign glyph,

SELECT '&gt;' || to_char(-1, '0') || '&lt;';
 ?column? 
----------
 &gt;-1&lt;
(1 row)


You can suppress the sign using FM, from the docs

Modifier Description Example
FM       prefix      fill mode (suppress leading zeroes and padding blanks) FM9999


So what you want is

SELECT '&gt;' || to_char(1, 'FM099') || '&lt;';


The zeros aren't suppressed when you demand them with FM0