Because they had no cave walls or canvas? Necessity is the mother of invention? Skin was always available?
We can never know who invented tattooing, and yes, it was a hell of a risk to take! I expect it often went wrong, by poisoning or by sepsis, in the early stages.
I've never had the urge to have a tattoo, partly because I don't like them much anyway, partly because it does hurt, though I've heard it's not too bad.