Sitecore best practice says to use datasource but habitat doesn't seem to follow this. At many places in habitat, content is in the item, instead of linked through datasource. Can someone explain me if there are any reasons behind this or best practise for this has not not been followed in habitat. Thanks
As we don't (yet) know which example you have in mind, I'll give my general opinion: although it is best practice to use datasources, it might not be best practice to use them for everything. Your content editors could go completely crazy if they need to quickly publish a news article and they need to create 5 datasources and a content item to achieve that (Sitecore will seem overwhelming to lots of people if you do that). Best practice is actually to think about your content architecture and create something that enables your content editors to work fluently and give them and the marketers the ability to do their (marketing) job - meaning let them personalize, test, etc.. renderings where needed.
Even in SXA not all components use a datasource. The title of the page is picked from the item itself. This does not mean you need to do that always, but in many cases it might be a good idea. Talk to the customer, the editors and the marketers that will administer the site and decide based on that information how the content should be structured (so they can do their job and the site is still performing well) and how and where to use renderings with datasources.
ps: sometimes it can also be a good idea to let an editor assign a datasource optionally (take the current item if no datasource was set).