Reduce list manipulation for QGIS layer tree
Your lists manipulations are indeed messy. It seems like you are trying to perform multiple things at once and thus you end up mixing variables that serve different purposes into the same loops.

Instead, you should try to extract logical steps to perform, such as:


extract informations you need from the internals of QGis to a similar but simpler representation;
compute the data you need out of this simplified representation;
format the data you computed for presentation;
use the formatted data to update your visual presentation.


Here the second and third step are simple enough they can be made at once.

But first, we will need an helper function to simplify the inner working of the first double for loop:

def is_visible_layer(layer, root):
    node = root.findLayer(layer.id())
    try:
        return node.isVisible() == Qt.Checked
    except AttributeError:
        return False


Now I’m not QGis expert, but I’m wondering if the root is really necessary to get the meta-information about the node. Isn't it possible to write it like:

def is_visible_layer(layer):
    try:
        return layer.isVisible() == Qt.Checked
    except AttributeError:
        return False


?

This let us write the for loop like:

for group in main_group.children():
    layer_list = []
    for child in group.children():
        if is_visible_layer(child.layer(), root):
            layer_data.append(child.layerName())
            layer_list.append(child.layerName())
    layer_count.append(len(layer_list))


Which can be simplified using list-comprehensions:

for group in main_group.children():
    layer_list = [child.layerName() for child in group.children() if is_visible_layer(child.layer(), root)]
    layer_data.extend(layer_list)
    layer_count.append(len(layer_list))


Now recall what I said about performing several things at once? Here you already try to count things while extracting the informations from the QGis internals. Let's get that for later and simplify the loop once again to build a list of list of layer names:

layers = [
    [
        child.layerName()
        for child in group.children()
        if is_visible_layer(child.layer(), root)
    ]
    for group in root.findGroup(main_group).children()
]


and then, only after you can start counting. And as it is much easier using this structure, you can start converting the list of list into a single list of couples that will mimic the table layout:

table = [
    (layer, len(group))
    for group in layers
    for layer in group
]


Turning this list of couples into an N × 2 table is then really easy. The whole code should look like:

def is_visible_layer(layer, root):
    node = root.findLayer(layer.id())
    try:
        return node.isVisible() == Qt.Checked
    except AttributeError:
        return False


def refresh_table(root, qTable, main_group='Main group'):
    # Get names of relevant layers, as a list of list of names
    layers = [
        [
            child.layerName()
            for child in group.children()
            if is_visible_layer(child.layer(), root)
        ]
        for group in root.findGroup(main_group).children()
    ]

    # Convert the layer list to the table layout i.e. a list of couples
    table = [
        (layer, len(group))
        for group in layers
        for layer in group
    ]

    # Configure output table
    qTable.setRowCount(len(table))
    qTable.setColumnCount(2)
    qTable.verticalHeader().setVisible(False)

    # Insert data into table
    for row, (layer, count) in enumerate(table):
        name_item = QTableWidgetItem(layer)
        name_item.setFlags(QtCore.Qt.ItemIsEnabled)
        count_item = QTableWidgetItem('{:.1f}'.format(1./count))
        qTable.setItem(row, 0, name_item)
        qTable.setItem(row, 1, count_item)


Call it like            

refresh_table(
    QgsProject.instance().layerTreeRoot(),
    self.dockwidget.tableWidget)