The correct option is D When it is forbidden by law
As per section 23 of the Contract Act, the consideration or object of an agreement is lawful, unless it is forbidden by law; or is of such a nature that, if permitted, it would defeat the provisions of any law; or is fraudulent; or involves or implies, injury to the person or property of another; or the Court regards it as immoral, or opposed to public policy. In this case, the agreement becomes void ab initio and illegal.