Is it okay to wear other people’s earrings?

Sometimes.
If you clean jewelry carefully with soap and water using a soft toothbrush or nail brush and then alcohol, you should be just fine so long as your ears are not recently pierced. While piercings are healing, you do not want to wear anything that could infect what is essentially an open wound that you are forcing to form scar tissue around a piece of metal. Do not share jewelry for an unhealed piercing, and keep it clean!
I’m old enough that my ears were pierced the traditional way by a lady from Catalan in her kitchen. She cleaned the ears with isopropyl alcohol then numbed them with ice. She made the holes with a sterile needle that had been run through a flame and threaded. The thing that looking back seems less than ideal was that she used a short piece of straw from a brand new broom that had been cleaned then cut up. This was what held the hole open after the first day or so. I cannot remember exactly how long the thread was left in the ear. I believe there may have been petroleum jelly or something on the thread as well. Once we were using the straw, I had to keep moving it periodically during the day after washing my hands, and the straw was replaced after each time my ears were cleaned. Eventually the straw was replaced with real gold earrings that still had to be rotated inside the piercing holes and cleaned daily.
We cleaned the earlobe 2 ل 3 times per day with hydrogen peroxide while it was healing. Because the placeholders were small, my holes are not as large as those pierced using a piercing gun at a store for example. Of the family members in 4 generations of women who had their ears pierced in that manner with a needle and oddly enough all using straw as the placeholder, none developed any infection or metal allergies.
Can you wear earrings previously worn by one friend? In families where fine jewelry is passed down to the next generation vintage earrings get worn by multiple women! Use some commonsense and our modern tools to thoroughly clean the earrings. Only wear what you have been told and no sharing in the first year that you are pierced just to be safely healed, then enjoy earrings as you like.
Personally, I clean earrings using mild dish liquid and a soft toothbrush first then alcohol. If I have rings that get dirtier because I’m handling more things that could get them greasy or earrings I wore while exercising, I might let those soak in soapy water a few minutes then scrub then let them soak for a little while in alcohol while I shower, then rinse and set them on a clean cloth to dry. Ooh. Sparkly!
No one in their right mind is going to throw out gold or platinum jewelry because someone else wore it. How would any royal family have a Crown jewels collection under such circumstances? Obviously, they share pieces within the same generation and pass pieces on generationally. Even the much more humble child size jewelry in my family gets passed along because a tiny hoop style earrings or tiny studs that look good on an infant or very young child won’t look appropriate with an adult’s size or possibly even fit around an adult’s earlobe.