I don't understand the importance of heap size limit of 6MB. So could someone help me understand the heap size limit?
The 6 million bytes of space for the objects that your code has in memory at once time is sufficient for the vast majority of code to work. You are only likely to exceed that space requirement and so get a governor limit exception if your code is doing something relatively unusual such as trying to hold a very large number of objects in a list or map all at once. Often such code is unintentional, and the governor limit protects other users from suffering performance degradation because of that unintentional code. Occasionally the governor limit does get in the way of legitimate code and can be more frustrating to live with.
You can see how much of the heap your code is consuming by adding e.g.:
System.debug('>>> heap=' + Limits.getHeapSize());
at various points in your code and looking for that output in the debug log. Usually your code will be a very long way away from hitting the limit.