Both are vector apps, but Illustrator skews more for, well, illustration and icon design, although you can use it for UI design. (You can also use Sketch for icon design too.)
Additionally, Sketch has a massive collection of plugins that forms a large part of it's appeal.
Adobe XD is Adobe's direct competitor to Sketch for UI design and for once, they are playing catch-up in terms of "mindshare" among designers. Making Adobe XD free in May 2018 was clearly an attempt by Adobe to accelerate the growth of their user base.
There are other competitors, notably Figma which is gaining a lot accolades and more users. Unlike Sketch, Figma runs in the browser which means you can use it on Windows and Mac (they have Electron-based desktop apps too). Sketch is Mac-only.
There is also Affinity Designer (Windows and Mac) - a vector drawing app which has a mixture of illustration tools (e.g. brushes) and more UI-focused features (symbols, constraints). However, Affinity Designer users seem to skew more towards illustration rather than UX design, so I would say they are probably not in the same race as Adobe XD/Sketch/Figma. Affinity Designer is a native app with no subscription model.
Overall, the more choice and competition in the design space is a good thing, particularly given Adobe's dominance. It's also nice to see apps adopt different UI approaches to tools - rather than copy the clunky way Adobe apps perform tasks.