There’s no one answer that’s true for everyone. It’s like asking how you can be the perfect spouse for someone: it depends on what the person is looking for.
But there are some norms and generalities. Some attributes that most people want from a friend are:
They can trust you because you keep their confidence, you don’t make fun of them when they make mistakes, and are otherwise sensitive to their feelings.
You act with their best interests, at least sometimes even over your own.
You’re candid with them, but not hurtful.
You’re interested in some of the same things
You enjoy each other’s company
Note that the are exceptions to all of these. Some people want to hang out with someone they feel superior to. Some people gravitate to people who reinforce their own inferiorities. Etc.