Why is buying stock options close to the expiry not allowed?
Fresh buy positions or long positions in the stock options in the last two days of expiry (i.e. Wednesday and Thursday) are not allowed since the contracts can become due for physical settlement. However, clients are allowed to exit the open short positions for the quantity they hold. To learn more about the physical settlement, see What is Zerodha's policy on the physical settlement of equity derivatives on expiry?
Margin requirements can exponentially increase if the client’s option contracts become due for physical delivery. Since stock options can be illiquid, it becomes difficult to exit the contract, which increases the risk for the brokerage firm.