The phrase in question is as if that ever works.
as if expresses a kind of unreality, similar to supposing or imagining or pretending.
Consider this direction given to an actor in a play:
Stroke your chin, as if you had a beard and were thinking up a clever plan.
as if can also express contempt for or the rejection of some notion (a suggestion or an idea or an explanation) because it has no chance of being true or of coming true.
He asked me to help him move to his new apartment. As if! When I
asked him to help me do the same two months ago, he said he was going
to be out of town on a business trip, but then I saw him in a restaurant
with his girlfriend.
...as if I would help him, after he was conveniently "out of town" when I needed help!
ever means "on any occasion" or "at any time".
So here in your example, the meaning is that the speaker is rejecting the notion that long distance relationships have worked out happily or successfully on some occasion. The implication is that the speaker believes they never work.
ever is an emphatic in the statement. It is not strictly necessary because the simple present can be used to express that which happens regularly or predictably. So, if said with the proper emphasis, the statement could have much the same meaning without the word ever:
... as if that works!
P.S. But "ever" has the sense that the speaker believes such relationships never work, whereas the form without "ever" might be understood to mean that the speaker believes such relationships fail regularly and predictably, but not necessarily always.