The context is missing, the question is too isolated, and the answers are very limited. The thread is incomplete.
First, for understanding, the presented Friend table does not exist on its own. It is a child of the User table which has an UserId PK. Both UserId and FriendId are FKs to UserId.
Since friendship is a two-way street or bi-directional (we are excluding unreciprocated lovers and stalkers here!), then a single row identifies the relation, in both directions.
There are strong implications in the naming of any column, so I would avoid (UserId, FriendId) which implies a hierarchy or a one-way relation, which is false. I suggest (Friend1, Friend2), and of course you need the PK to be ((Friend1, Friend2).
What has not been identified is, we have still not prevented duplicates ( [5,12] and [12, 5] ), the very redundancy you are seeking to prevent. We need a rule, to enforce an order, that Friend1 is always less than Friend2.
There are other relations, such as Bill of Materials or a family tree, which has Assemblies and COmponents, which require something more. Eg (AssemblyId, ComponentId) or (ParentID, ChildId) where that rule does not apply: a part can be a Component in an Assembly and also be an Assembly itself. That requires two rows. Still no duplicates.