Was sin considered as a flaw in microcosm that leads to the decay of macrocosm? Does Hamlet by William Shakespeare illustrate this?
For a brief but excellent treatment of this theme, I would strongly recommend that you read Tillyard's The Elizabethan World Picture.
Essentially, Shakespeare, as many other writers of his period, believed in the notion of a chain or hierarchy of being (a metaphor based on the Pythagorean golden chain) running from God at the top to the least noble elements of the mineral kingdom at bottom. Everything in the world was linked to everything else and could affect it by the laws of sympathy. The king was especially linked to the kingdom as microcosm to macrocosm, and flawed or sinful rulership both embodied and caused corruption throughout the kingdom. The king, being the most godlike in power and honour, member of the kingdom, essentially connects the kingdom to heaven; corruption in the human and celestial worlds have reciprocal effects in disturbing universal harmony. Thus, when Hamlet says:
The time is out of joint: O cursed spite,
That I ever was born to set it right (1.5.188-89)
he is suggesting that the sins of the rulers have macrocosmic effects and that his murder of them will restore the time as a whole to harmony.