The Court wasn't "in favor of it", per say. It was simply the removal of restrictions placed on it by lower courts in a majority 7-2 decision. More specifically, the Court can only interpret the laws, so when it comes to Executive authority, they apply the black-letter law as it is written, which gives the president the authority to engage in such matters. If you understand how the law works and the way the justice system operates, it should have been no surprise. They were initially filed in circuits that are routinely overturned by the Supreme Court.
As for context, the original draft was intended to place a temporary ban on the listed Muslim-majority nations until the DHS could implement extreme vetting. I think the timeline was about 6 or 10 months, but that period has already ended, so regardless of what the SC decided, it would have had no effect on its implementation. At this point, it seems to be a game of political ping-pong that the Executive branch will most certainly win because the office is bigger than one man. Just because the President might seem to have some evil ulterior motives does not give the courts authority to muddy the waters concerning laws for national security priorities, laws that every president needs at their disposal given some unforeseen event.