Why can Shylock can be considered the villain of The Merchant of Venice?
In a world in which Bassanio and Antonio can be vain and foolish and absurdly pledge to pay a debt, taken from a man whom they persecute and despise and unfairly treat with physical and verbal abuses, by the extraction of a pound of flesh, then an enraged Jewish moneylender can be cast as the villain. Is this a just position in which to cast Shylock? Unfortunately, yes, because of two things. The first is that he asks for a forfeit repayment that is against the law. Second is that he violates his religious faith.
Shylock knows full well that cutting a pound of flesh from a man will kill or grotesquely maim him. He also knows full well that such a contract is a violation of the law of the land. He also knows full well that a court battle would be required to permit him to carry the contract out and that, since it violates the law in the first place, it is highly likely that he would lose his court suit.
Shylock's faith of Judaism prohibits revenge. The Pentateuch Books of the Laws (a portion of the Old Testament) clearly state that revenge belongs to G-d and that Jewish people are not to seek revenge. King David often beseeches G-d in the Psalms to take revenge against David's enemies because he himself may not, must not. Yet Shylock designs the contract of forfeiture precisely for revenge. This is confirmed in his soliloquy in which he states that a Christian's first response to an offense is revenge, therefore his response to accumulated offenses will be revenge; he will follow the Christians' lead.
Shylock pays dearly and ironically at the end of the play for abandoning his faith and adopting Christian practice (which, incidentally, is also a violation of Christian faith). Shylock's legal punishment when he loses his case in court includes a mandatory conversion to the Christian faith, anathema to Shylock.