I want to know the purpose of routing the urls. Can anyone explain me why do we route urls?
Hard to give a precise answer without more detail, so this will be oversimplified, perhaps too much so, but I'll try.
Joomla URLs natively look like someone dumped part of a can of alphabet soup on the screen. Joomla uses those numbers to find the content being requested, but why should a site visitor have to put up with such a jumble? And what is a search engine to make of that URL? (/sensible/human/readable/link as opposed to index.php?option=com_whizzbang&Id=23&morearcaneitems=toomany even makes more sense to a search engine trying to classify the page it's indexing.)
The routing system in Joomla provides a mechanism so that when that content item's name changes, or category, or pretty much anything else, the original link can still be used by the router to find the modified page. Without a routing system none of the items in the query string could ever change without having to change the URL. What if a visitor bookmarked a page? Or you emailed someone a link to your site. When you made that little change, that item got lost and none of those links work any more. With a routing system in place, Joomla can use it to figure out whether this received query string fits this modified page, instead of just giving your visitor a 404.
We use the routing system to output links for much the same reason; it's a quick and simple way to create a consistently-formatted URL that Joomla will be able to use to find the page again, and if the page changes, the call through the routing system will pick up the changes automatically, so every navigation link in the site will now use the current real URL.
It's a chunk of a larger practice known as "encapsulation" where you hide the details part of the system needs to know away from the other parts of the system that don't need to know them. That makes the code easier to maintain because if those hidden details change only that one part of the code needs to change.
In the case of the routing system, this hides the details of the Joomla internals from the rest of the world, giving you the ability to change them as you need without impacting the ability of the rest of the world to find your page. Without the router any time you decided to move an article to another menu or category, the query string would be different and anyone with the old query string couldn't get to the page.
Hope that helps.