A habitat is the physical environment in which an organism lives, while a niche is the role an organism plays in its environment. In other words, a habitat is the place where an organism lives, while a niche is the function the organism fills in that habitat.
A habitat is a large-scale environment, while a niche is a very specific role an organism plays within that environment. For example, a pond is a habitat that can be home to many species of organisms. Each organism in that pond has its own niche, such as the algae that provides food for the fish or the fish that eat the algae.