Sniffing your groin is basically the dog version of a polite handshake, and it’s analogous to the mutual butt-sniff-and-circle behavior you see when dogs meet.
Dogs have anal sacs (often called anal glands) on either side of their anus, and those are full of stinky information about the biology of the dog. Dogs have noses that are 100,000 times more sensitive than human noses, and the chemicals, pheromones and bacteria contained in those sacs can tell another dog a huge amount of information about the owner of the butt, including gender, where they are in the estrus/reproductive cycle, illness, stress, diet, and maybe even current emotional state.
Humans don’t have anal glands, obviously, but our groins contain lots of the same information! We’ve got sexual secretions that contain lots of pheromones, the end of the digestive tract, and a place where sweat and dead skin cells often accumulate.
Sniffing our groin is basically just a dog learning everything it needs to know about you super fast (except maybe if you have cookies, because most pockets aren’t over our crotch). It’s like a personal ad you didn’t know you’ve written, and in dog, it’s just polite!