As with de-boarding most time is wasted/spent by people standing in the aisle and waiting for someone who is putting their luggage in. The optimal solution has as many passengers loading their luggage in the overhead compartment in parallel as possible. The ideal way to do this would be that we first have passengers with window seats board with one person for each row. We should only use every other row to ensure people can maneuver. So we'd first board seats NA, N-2A, N-4A, etc. down to row 1 with N being the last row. Then NF, N-2F, N-4F etc. And then N-1A, N-3A and so on. Then we work our way through the middle seats and then aisle seats.
The current approach which commonly boards people starting from the front or back FORCES congestion and minimizes probability of two people reaching their seat at the same time and being able to put up their luggage in parallel.
Even if the approach I describe is broken because groups board together, it becomes at worst a random boarding order which is still much more efficient than the current nonsense.
The reason we cannot board more efficiently is because it's unintuitive, people don't like it and behave like wild animals in groups.