It's legal because the legislation gives them the authority and latitude to refuse applications for personal, financial, criminal, political and a host of other reasons. Don't like it, there is always the option for judicial review and failing that you can appeal to a higher court.