Habitat is a Latin verb masquerading as an English noun. In Carl Linnaeus's 18th-century taxonomic system, each species description included a line beginning 'Habitat in...' — Latin for 'It dwells in...'. English naturalists borrowed the word directly from these descriptions, dropping the rest of the sentence and keeping only habitat as a noun meaning 'the place where a species lives'.
The Latin habitāre ('to dwell') is a frequentative of habēre ('to have, to hold'). The logic is that to dwell somewhere is to hold it as your own — to have a place. This connection runs through the entire word family: a habit is something you hold to repeatedly, inhabit means to hold a place within, and exhibit (ex-habēre) means to hold something out for display.
More distantly, able descends from Latin habilis — 'easy to hold or manage'. A capable person is one who can be held in hand, metaphorically speaking. Prohibit (pro-habēre) means to hold something forward as a barrier.
The Proto-Indo-European root *gʰabʰ- meant 'to grab' or 'to take'. From grabbing to having to dwelling: the semantic drift covers the full arc from seizing a place to calling it home. Habitat preserves the middle of that journey — the moment when having becomes inhabiting.