The first Thanksgiving was in 1621 after the Pilgrims first harvest.
In 1863, after a series of editorials and an appeal by writer Sarah Josepha Hale, Abraham Lincoln declared the last Thursday in November to be the national Thanksgiving Day.
In 1939, President Franklin D. Roosevelt declared that Thanksgiving would be the next to last Thursday of November. This was established in hopes of helping the U.S. get out of the The Great Depression. This provided merchants more time to sell goods before Christmas. Back then it was deemed improper to market Christmas merchandise until after Thanksgiving. This decision was not mandatory, and 23 states participated on the new day, 22 did not. Texas could not make up its mind and ended up taking both weeks as holidays (funny).
In 1941, The U.S. Congress officially recognized a new date and brought the states back in synch. Thanksgiving would now occur annually on the fourth Thursday of November (sometimes the last and sometimes the next to last).
Read more details and history on Thanskgiving.