What did Samuel Johnson mean when he wrote this?

Solution 1:

This is an old-fashioned use of the word but to mean something like "without".

  1. [with negative] archaic Without it being the case that:
    'it never rains but it pours'
    Oxford Dictionary Online

So the second half of the quote could be restated as

...so that almost every time two people meet, one of them will be offended by the ostentation of the other.

Solution 2:

This usage of "but" is a bit archaic. When an expression of impossibility or unlikelihood combined with "but", but phrase or clause introduced by the "but" describes an exception to the previously stated rule. As Macmillan puts it:

  1. used after negative statements for saying that something does not happen without something else happening or being true

Macmillan designates this usage "formal", but I'm sticking with "archaic".

In your quote, therefore,

scarcely can two persons meet

is the expression of unlikelihood, and

but one is offended or diverted by the ostentation of the other.

is the exception to that unlikelihood. That is, Johnson asserts that meetings characterized by one person being offended or diverted by the ostentation of the other are not scarce, in fact, he's saying that such meetings are the overwhelming norm.

Note that that is similar to what you said, but not quite the same. Johnson does not assert that when two people meet, one of them always is offended or diverted by the other. Rather, he asserts that the meetings where that does not happen are scarce. And I take the assertion as somewhat hyperbolic.

Solution 3:

This is an archaic use of but. In this context, but is “introducing an inevitable accompanying circumstance or result”. (NED V1 A–B) That is, you can replace “but” with “without the inevitable result that” without changing the meaning:

Scarcely can two persons meet, without the inevitable result that one is offended or diverted by the ostentation of the other.

In modern constructions, the word without is used instead, and the dependent sentence is recast using be and a gerund:

Scarcely can two persons meet without one being offended or diverted by the ostentation of the other.