The Supreme Court struck down the Texas sodomy law on the basis of substantive due process. It appears (though this is somewhat contested) that the Court used a “rational basis” test to do so.
In general, courts allow legislatures to make any laws they like. They only step in when those laws discriminate excessively and unnecessarily against a given group. The courts have said that laws that discriminate against some groups should get “strict scrutiny.” These are laws that discriminate on the basis of things like race and religion. A law that discriminates in this way must have a “compelling state interest” and must be narrowly tailored to achieve that interest. However, the Court did not choose to say that homosexuals were a group that should be protected to this degree.
Instead, the Court simply asked if there was a “rational basis” for this law; it asked if the law was connected to some “legitimate state interest.” Almost every law that is scrutinized at this level is allowed to stand. In this case, however, the law was struck down. The majority decision said the law was not related to any legitimate state interest and therefore was unconstitutional.