(as said in his history, but expanded a little)
Espionage was part of an autobot initiative for making the perfect infiltration unit, but the project was cut short from completion so the units still did not have complete shapeshift capability. After watching the rest of his kind be slaughtered in open battle he fled, deserting his post and running to an outward colony. After a hundred years he came back disguised as one of his fallen comrades, and kept fighting in the battle until the autobots fell to earth, which then he returned to being in his actual physical form.
Its very complex shift tech
Here's how it works:
While he cannot have flesh and organs, he can trick devices into thinking he is human by giving off the heat and other vital signs. Metal detectors, however, would pick something up, but an xray would show him as an ordinary human. Because only lead will block xray, he makes 'bones' out of a lead alloy that look just like human bones in an xray. His metal can change colors to accommodate for cybertronians not always being the same color, so he can make his outside husk smooth like human skin and make it the appropiate color. And yes, he does shrink down.