It's not illegal per se, if you adjust transmission power accordingly. Router manufacturers generally don't use yagi because it's directional, requiring aiming, unlike omnidirectional dipole antenna. Modern wifi stations have much more sophisticated ways to increase range than passive antenna designs.