On the ex-dividend date the stock opens lower by roughly the dividend amount, because the cash has left the company. Buying the day before to capture the dividend does not create free money.
Dividends affect options: deep in-the-money calls may be exercised early to capture a large dividend, which means assignment risk for call sellers. Short sellers owe the dividend to the lender.
Example: a $100 stock pays a $1 quarterly dividend. On the ex-date it opens near $99, all else equal. The yield is 4% a year.
Related: assignment, exercise, short-selling, etf