A habitat is where an organism or a community of organisms lives, and a niche is the specific place an organism has in an ecosystem. A habit can help define the niche of particular creature but cannot describe it entirely.
A habitat can range in size from a host creature where parasites live to a grove of trees or a pond to things much larger. They must provide the organisms that live there with what they need to survive such as food, water, oxygen and minerals. If the habitat provides these things to the organisms that live there, those creatures will stay in the habitat. If these needs are not met, however, the organisms that live there will move elsewhere.
A niche, on the other hand, reflects an organism's behaviors and other variables like wind or temperature that affect those behaviors. Evolution helps species adapt over time until it evolves to successfully fill a place within a certain environment. Some species evolve so well, however, that it may no longer be suited to another environment. It is also possible for similar environments to help similar species evolve that do not live close together. For example, cattle in North America and wildebeests in Africa are similar because they evolved in similar niches in their environments.