When the internet first started it was mainly for universities and other seats of learning (and the military), nobody ever forsaw the massive growth in its use by business and for personal web sites.
The letters at the end were supposed to give an idea of what the domain is used for.
So .COM (company) was for a worldwide business, like say www.ford.com.
As wikipedia says, EDU was education, GOV was government, MILwas military and so on.
Then as the internet grew individial countries wanted their own extension so UK was introduced for UK.
So a UK only company could set up www.computers.co.uk.
Over time other extensions were added like TV, for TV and media companies.
There are very little rules and anyone can set up a COM domain.
I could start a small company in my bedroom called FRED99 and buy the domain www.fredd99.com but it would not mean I was a worldwide company.
Any domain that is free can be bought by anyone.
Some people deliberately buy domains they dont want, like www.ford.co.uk, hoping that the ford company will want to buy it off them.
So the extension gives a ROUGH idea of what the site is for, but it is not fully accurate.