I don't think Ukyou's legally a boy....
According to her -school records- she is.
Ranma 1/2 has a lot of bits in it that work better if you accept anything that
would belong in an old martial arts movie even if it's weird in 1997. Seen in
this light, Ukyou's legal status doesn't matter because in martial arts movies,
women pretending to be men is pretty normal. A lot of other stuff like Ryouga
wandering, strange tribes with strange marriage customs, Nodoka letting Genma
train Ranma for 10 years, etc., makes more sense when you think of it this way.
Obviously, it's not all like this, and in fact some of the humor comes from
the conflict (Ryouga on one of his trips in the mountains... cooking instant
ramen...) but much of the weirdness in the series does fit this pattern.