There were 2 questions.
Can I invest in stock prior to its ex-dividend date, then sell after and still get the dividend payout?
A detailed explanation can be found in this article : Dividend implications. If you are thinking of getting the dividend and selling the stock its price is adjusted price, it is not going to happen. There is a chance that a few careless investors forgot to adjust the bid price with an automated system, but usually, those systems will notify the investor.
Is there any benefit to buying the stock way earlier -- say, in January?
Short answer: You cannot go very wrong if you buy low based on fundamentals.
Long answer: If you buy based fundamentals and think the stock price is below market value (e.g. a Price Earning ratio below 15) and the company has positive cash flow, little debt, etc., then you will not lose money unless the company cooked their books like WorldCom, Enron, etc.). On the other hand, if the stock is volatile due to speculation, then the investor must watch out for signs of an overpriced stock (a P/E ratio higher than the industry average).
Note that it is not illegal for a public listed company to pay out dividends if is not making profits. So investor must always watch out for fundamental than blindly walk into the dividend payout trap.