It looks like service academies in US have some extensive requirements such as "Unmarried with no dependents or financial debt". How is this justified? I would expect a higher education institution/employer to be flooded with lawsuits if they ever use something like this.
There is no federal law against discrimination based on having debts or dependents. Marital status discrimination is prohibited for civil service employment, but USCG academy admidsion is not civil service employment. There is also a presidential order prohibiting discrimination based on parental status in federal employment, but again this is not employment and it is also not about parental status, it's about any kind of dependents. Since it's not prohibited, nobody would have standing to sue.
All students at the various U.S. Military academies are considered active duty members of the U.S. military and have taken the oath of induction prior to official enrollment. With regard to students at the service academies the Uniform Code of Military Justice supercedes certain civil protections afforded citizens who are not active duty members of the U.S. military.
In general, discrimination is perfectly legal. You got the job and he didn't because your resume is better than his.
Some discrimination is illegal, details vary by jurisdiction, for example discrimination on the following bases is illegal in Australia:
- sexual preference
- physical or mental disability
- marital status
- family or carer’s responsibilities
- political opinion
- national extraction
- social origin
However, there are some organisations that are exempt, for example, a church can discriminate on the basis of religion and ASIS (Australia's CIA) is totally exempt. There is also a general exemption when one or more of these traits is a requirement of the job; this is especially relevant when hiring actors but a case can be made in other circumstances.
Positive discrimination is legal on the basis of a number of these traits.
Depending on the particulars of the law where you are, this is probably fine.