For me, it's really about who. A hug may brings into focus what exactly the relationship is, and if it is querulous, undefined, unreciprocated, with hidden agendas, secrets and lies - how can the hug not radiate all that?
Whereas sex is like a handshake - the original use of which was to prove you held no weapons, so therefore proximity was safe. No such guarantee in a hug.