Before diving into the Ex-Dividend date, let me explain you about the Record date. Many people are buying and selling shares in the share market, leaving the market price volatile. Everything will be going fine until the dividend payment arises. There the company has to decide to whom the dividend has to be paid. To clear out this confusion, every company brings in the term "Record date". It is a particular day set by the company in order to keep a record of the shareholders of the company as on that date, so that it could determine to which shareholders it has to pay the dividend. Ex-Dividend date or Ex-Date is the day immediately preceding the record date. The shares bought on or after the ex-date are not eligible for dividend. One will be eligible to get dividend on the shares purchased, only if the person has bought the share before the ex-date. This is because since the shares are traded in the share market on T+2 days basis. That is, if a person buys a share just before the ex-date, he will get the shares after 2 days (on the record date). Thus he will be eligible to get the dividend on those shares. Let me tell you the scenario:
Let's assume Mr. A, a shareholder, has bought 100 shares of AD company on 7th june, 2021. The share price is Rs. 100 and the company has declared dividend of 30% on its shares. The company has set its record date as 9th June, 2021, making it's ex-dividend date as 8th June, 2021. Therefore, Mr. A has bought shares on 7th, and he will receive the shares on 9th June (T+2 days). Hence, he will be recorded as the company's shareholders as on that date, and will be eligible for the dividend receipt.
Thus, the shares bought on or after ex-date (8th June) will be credited to the person's demat account after 2 days (10th June). He/She will not be in the record of company's shareholders, and won't be eligible for the dividend.
Next is the drop of market price after the ex-date. Some people buy shares with an intention to make short-term profits, some plan for long-term investment. Some buy shares to get a decent dividend in addition to their profits. This will be mostly in the case of short-term traders. So when the ex-date is over, those people tend to sell the shares quickly, leaving an increase in the supply of shares. Therefore, the value of shares will fall down due to the insufficient demand for the shares. Yes, this happens most of the times, particularly because short-term traders play a vital role in the market price of shares.