外 = 夕 (evening) + 卜 (to divine). Divination was normally done at dawn; doing it at dusk (夕) was 'outside' the proper time — irregular, beyond the norm. From 'beyond' came 'outside'.
外 is the opposite of 里: 外面 (outside), 外国 (a foreign country — 'outside country', pairs with 国), 国外 (abroad), 外人 (an outsider). 老外 is a casual, usually friendly word for a foreigner. The inside/outside split (里/外) runs deep in Chinese thinking about family, group, and belonging — those 'inside' your circle are treated very differently from those 'outside'.
Divining at evening (夕) — off-schedule, OUTSIDE the norm.
外国人 = foreigner ('outside-country person'); 老外 is the casual, usually warm version. The 里/外 (inside/outside) divide shapes how Chinese culture thinks about who's 'family' and who's not.