As already described in Dan B's answerDan B's answer, the normal way to distribute loot is to decide which character can best use it, and give it to them. It doesn't matter which character opened the chest, the discussion from the start should have been who would best be able to use it - putting you in charge of 'distributing' it was not a good choice for several reasons.
To clarify - it was not right of the other player to decide, for themselves, that they would steal the sword from you. You are right to be upset at this - but clearly they were not satisfied with this arrangement in the first place.
Not to mention - using a magical weapon like this requires magical attunement in 5e, so being a 'sword distributor' doesn't even make sense in terms of pure game mechanics.
In short - no matter your reason for wanting the sword, this is a poor idea and will not work out in the long run. You should open discussion with your group about who should have the sword, and understand that there will always be chances for you to find more magical weapons.
Remember - at a certain level of wealth, each character should be able to just buy a magical sword if they don't have one - so the need for this overly complex arrangement is minimal.