The term itself likely stems from the commonplace practice of subordinate employees or officials being deputized and given the authority to sign the name of their superior or employer. In situations where this superior official's signature may frequently be required for routine paperwork, a literal rubber stamp is used, with a likeness of their hand-written signature. This could also be utilized personally by the individual named on the stamp, to prevent hand fatigue and save time when a large number of documents need to be signed. In essence, the term is meant to convey an endorsement without careful thought or personal investment in the outcome, especially since it is usually expected as the stamper's duty to do so. In the situation where a dictator's legislature is a "rubber stamp," the orders they are meant to endorse are formalities they are expected to legitimize.
The metaphor can also be used as a verb, to rubber-stamp.
Among auditors and military personnel, the synonymous term "pencil whip" is common.