The Thanksgiving Holiday grew out of harvest festivals held by people since the beginning of time usually at the end of the growing season to celebrate a good harvest and to give thanks. The United States tradition is tied to a celebration supposedly held by the pilgrims in 1621. Different days were proclaimed by colonial governors until 1789 when President Washington proclaimed November 26 "as a day of public thanksgiving and prayer to be observed by acknowledging with grateful hearts the many and signal favors of Almighty God".
Thanksgiving was first celebrated on the same date in all the states in 1863 by proclamation of President Lincoln due to campaigning by author Sarah Josepha Hale who wrote letters to politicians for 40 years promoting a national day for the holiday. Hale was the editor of "Godey's Ladies' Book" and author of "Mary Had a Little Lamb".
Thanksgiving existed every year by proclamation of the president and was always the last Thursday of November until 1939 when the last Thursday was November 30. The depression was still going on and merchants thought that if there was more time between Thanksgiving and Christmas people would buy more. They pushed President Roosevelt into moving the date to the week before. This caused a huge uproar. School holidays, tests and football games had to be rescheduled. Many states stayed with the original date and confusion reigned until 1941 when Congress proclaimed the holiday to be on the 4th Thursday of November.
Some information from Wikipedia.