Harvard University and the Massachusetts Institute of Technology have sued the Department of Homeland Security and the federal immigration agency over new guidelines barring foreign students from remaining in America if their universities switched to online-only classes in the Fall.