One of the distinguishing features of American political governance is the concept of separation powers. The separation of powers basically means that there are three co-equal branches of government, the executive, the legislative, and the judicial. Each of these is a check on the others. It is not unusual for presidents to criticize the court but it is actually not very often, if ever, that a president openly challenges the supreme court in that fashion - particularly when there is a big pending case before them. Historically the Supreme Court has made some rulings that have supported injustice such as the Dred Scott decision in 1857 that found black slaves to not have standing to sue and that slaves were not citizens. That decision created fervent debate and Lincoln, the second Republican president, ran as an abolitionist. Consequently, the Supreme Court is, obviously, not infallible; nor is it immune from criticism. However, criticism should occur after and not before a ruling.
There has been a lot of discussion on the lack of civility in public life and the president is not providing a very positive example of civility when he openly criticizes a co-equal branch of government. This is the second time he has done so. Check out the video below where he publicly criticized and embarrassed the Supreme Court during a state of the union address. Remember that the Supreme Court are invited guests and are not obligated to be there. They are a co-equal branch of government and are not part of the legislative body.
Judge for yourselves the appropriateness of his comments in this clip.