Irving give us a hint at one of the reasons Rip might decide to take a walk into the mountains when he describes Rip as a "simple good natured man; he was moreover a kind neighbor, and an obedient, hen-pecked husband." One of Rip's goals on any given day is to get as far from his wife as he can, and one of the acceptable ways of accomplishing that goal is to go hunting. Most people in that time period supplemented their diet through the hunting of wild game, and one of Rip's "tasks" as the husband and family provider, is to provide meat, generally squirrels, for the table.
Another reason for going hunting lies in Rip's nature: he's extremely lazy. Although he does odd jobs for neighbors and makes toys for the village's children, he avoids his own domestic chores as much as possible. Again, hunting, which allows him to avoid both his wife and his chores, is a socially acceptable way of avoiding doing all the things he finds tedious because it is both practical and expected (in Rip's case, only in theory).
From a literary perspective, of course, Rip has to go into the mountains in order for the essential plot to develop--he must go to a place away from the world of men in order to meet magical beings, who cast a spell upon him that allows him to sleep through twenty years.