As a non-American, it's easy to make assumptions about what state capitals are in the US based off the largest and most famous cities there: surely, one might assume, NY is NYC, California is LA, Washington is Seattle, Florida is Miami, Oregan is Portland, Louisiana is New Orleans, Illinois is Chicago, etc.
However I was shocked to discover that in almost every state the capital is often a much smaller town that I've rarely, if ever, heard of (NY is actually Albany, California is Sacremento, Washington is Olympia, Florida is Tallahassee, etc.)
Now, there are some rare exceptions (Phoenix, Arizona and Salt Lake City, Utah notably) and I'm sure every state has their specific reasons for choosing their state capitals, but are there any general trends or overarching historical reasons why big, notable cities seem to be spurned for the capital status?
There are several factors that have resulted in smaller communities becoming and remaining state capitals.
The first of these is historical, namely that a place was selected at an early point for various reasons that made sense a long time ago. Then, despite discussions about moving the location, nothing has come of it.
A second common reason for the selection of a small town as capital was a desire to locate a capital in the center of the state. This is clearly not always a criterion, but when it is, it can explain why a small town was and remains the capital. In this situation as with capital sites selected for other reasons, we have to understand that sometimes being a capital results in a place becoming larger than it might otherwise be. That is a response to other historical forces that can cause a small place to grow larger because of the presence of state government.
If a small town is selected for various reasons to serve as a capital, it can then experience a great deal of public spending to build the structure of government - a capitol and various government office buildings - and this can discourage moving the site of state government if and when population trends leave a place behind.
Then there is also an interest on the part of legislators to do the business of state government away from prying eyes. Sometimes it is good, frankly, to consider legislation in a smaller town so that large numbers of protestors for one point of view or another (or both) don't show up at hearings. Large cities aren't always conducive to the careful consideration of legislation.
There is also a common inclination for the largest city to avoid becoming the capital because having the capital and most of the people can foster resentment. In the UK, people often speak with resentment of the power of London - gobbling financial resources and calling all the shots at the same time, leaving the hinterland starved for support. Sometimes it is better for the tail to wage the dog. New York City obviously has outsized influence on state government; imagine how deep the resentment would be if it also had possession of state government - best to have the capital located upstate so the perception of a monopoly on power and money is reduced.
I'm sure there are other factors we could think of, but by my experience, these have been the causes of sometimes-smaller communities being selected and remaining as the capital.
edit: some very good points have been raised in question of the third point - the idea that some legislators prefer to conduct their business in relative peace. I saw this as a factor in Nevada when there was repeated discussions about moving the capital to Las Vegas. Carson City is hundreds of miles from the largest population center, which inhibits public participation. There is of course a great deal of coverage of issues as they are deliberated, but enormous protests - which would occur in Las Vegas if it were the capital - are not as easily gathered in relatively small Carson City. That said, let's regard this factor as possibly unique to Nevada and move on.
edit #2: some good comments/questions have been removed dealing with my first edit. Apologies; I hope I have addressed the questions that are no longer visible.
This question has been asked before. There are a number of good answers and discussion in this thread from 8 months ago, with answers from /u/back-that-sass-up and /u/greed_and_death, as well as a link to an answer focusing just on NY from /u/discovering_NYC.