The townlands are the oldest land divisions we have - much older than parishes, baronies or counties. If the borders seem random, that's becuse they are based on patterns of settlement and land use that in most cases disappeared centuries ago.
As a rough rule of thumb, in areas where the land is richer or more productive, townlands are smaller in size. This suggests that the townland was probably related to the productive capacity of the land - a townland should support so many head of cattle, or yield so much crops, or support so many families. But the specific criteria used may have varied from place to place, depending on (among other things) the type of agriculture practised in the area.
The -town suffix in anglicised townland names is often a translation of baile in the original name; this is true also of the Bally- prefix. In modern Irish baile means a town, but Gaelic Ireland didn't have urban settlements so it can't have meant that then and, unfortunately, we have no real idea what it did mean, except that it probably indicated some kind of settlement.