The query you wrote first creates a cartesian product between all pairings of person nodes, then does filtering on each pairing to find the ones that are actually related, then creates the relationship. That is very expensive, an n^2 operation.
Instead, you may want to go through all Person nodes just once, and find the corresponding person node with the property, and create the relationship.
Also, you should see greatly increased performance if you have either an index or unique constraint on the property in question, otherwise it will be a node scan over all nodes in that label with each comparison, another contributing factor to the slow query.
Also, I encourage you not to return the nodes and relationship if possible, assuming that it's in the neighborhood of thousands or hundreds of thousands of results. That's probably another factor.
match (p1:Person)
with p1
match (p2:Person)
where p2.someproperty = p1.someproperty and p1 <> p2
merge(p1)-[r:Relationship]-(p2)
You should be able to EXPLAIN both this query and your old one and see how they're both going to run.