The First Amendment is not absolute... it does have its limits. For members of the military, who take oaths to protect the Constitution, the nation, and the President, they are limited as to what they can publicly express. Each member of the military, upon enlistment, must take an oath addressing their rights and responsibilities as members of the armed forces, part of that oath includes, " I will obey the orders of the President of the United States..."
The Facebook post which has led to Sgt. Stein's discharge reads as follows, "Screw Obama and I will not follow all orders from him." Clearly such a statement appears to be in violation of his oath and by extension his responsibilities as a soldier. Sgt. Stein said he meant that he would not follow illegal orders and that his comments are protected by the First Amendment.
The decision reached by the Marine Corps. essentially states that while Stein has the right to make such statements, he does not have the right to serve in the corps.... that is a privilege.