The SCOTUS imposed the exception on Trump's order for families and relationships for several constitutional principles protecting rights of families like due process and equal protection. A recent example can be  found in Obergefell v. Hodges in Justice Kennedy's majority opinion on right to marry. Violation of equal protection, religious freedom (how religions view grandparent relationships) and due process come into play when the SCOTUS exception for relationships like family relationships was drafted by the government to allow for example in-laws (brother, sister, etc.) but not grandparents.