Well, at this stage in US History, the country was post-Reconstruction period and attempting to navigate the societal impact the sudden freedom of thousands of formerly enslaved persons. Generous concessions were made to the South following the assassination of Pres. Lincoln and the installation of Pres. Johnson--a southern Democrat--into the White House. Pres. Johnson was staunchly opposed to the 14th Amendment, which extended citizenship to former slaves when it was ratified in 1866. He was against extending the rights of personhood and equal treatment to African-Americans, and he echoed or amplified the desires of elected officials in newly reconstituted Southern state governments.
Many racist-based laws which came to be known as the Black Codes were attempted during Pres. Johnson's term. The Black Codes were essentially replacements for the slave codes, with the intent behind them being to limit the rights of newly-freed African-Americans and restrict their movements. These laws seemed to be push-back against the rapidly changing societal norms brought about by the South's defeat in the Civil War and with that defeat the enforcement of the Emancipation Proclamation, and the subsequent passage of the 14th Amendment. In order to maintain the previous system of enforced white supremacy, laws were passed to maintain separation of the races in most social interactions. Concerns about the constitutionality of these laws is why the Supreme Court took up the issue in Plessy vs. Ferguson.
Plessy vs. Ferguson basically created a compromise that only enhanced the perceived inferiority of African-Americans and maintained a racially-based caste system in the US. The decision was, in essence, that as long as the accommodations or resources for African-Americans were of equal quality, segregation was ok. This was the enshrinement of the "separate but equal" concept into US law. So in Mr. Plessy's case, him being able to purchase a ticket and ride on a train was not being denied; he only had to do so in the part of the train reserved for members of his race. See? No problem here! What's so unfair about that? This way white passengers don't have to be offended or feel threatened by his presence and Mr. Plessy gets to ride the train with his own kind. Everybody wins--or not. As we later found out, the accommodations and resources for African-Americans were rarely equal and the disbursement of funds for these endeavors was rarely proportionate to white resources, and this was particularly evident in education and healthcare.
Plessy vs. Ferguson would be the law of the land until the decision in Brown vs. Board of Education upended it in 1953.