There are two ways to approach this question.
First, we can ask why it is possible for such discrepancies to exist. The answer to that, in the United States, is federalism. Our system of government was set up to allow the states to have significant autonomy. One aspect of this autonomy is the right to control their own educational systems. Because our Constitution gives this right to the states, different states can spend different amounts on their students.
Second, we can ask what factors cause the states to decide to support education at different levels. There are at least three major factors that are relevant here. First, different states simply have different costs. For example, Wyoming will typically have a lower cost of living than New Jersey. Therefore, it is possible to pay teachers less in Wyoming and still attract people to the profession. Second, different states have different abilities to pay. Mississippi, for example, is a poorer state than New York. Therefore, it has less tax revenue to use to pay for education. Finally, different states have different dominant political philosophies. More conservative states are less likely to want to spend lavishly on education. They will want to provide a good education, but will be less likely to want to pay for things that they would see as government-provided frills.