It's important to understand that a dividend from a stock is not "free money." On the ex-dividend date, all else equal, the company's share price is adjusted downward by the amount of the payout.
The value is simply being transferred from the company to you. Prices can move during the trading day, but that adjustment reflects a basic accounting reality.