There's several things to keep in mind that can help. I also would prefer to approach discussion as an argument as that is the most direct way to learn and clarify your own thoughts. Unfortunately due to how people are, the situations where argumentation is actually effective for that purpose are all too rare.
I try to approach most online discussion from a perspective of understanding rather than trying to convince, argue, or prove something. This also directly aligns with the goal of learning, because, well, that's what I'm trying to do.
The first thing it helps to realise is that every individual is at a different level of understanding. Not everyone cares that much about learning & understanding, so often people are just repeating things they've heard and internalised. It takes work and time to "unstick" people who are like this from their current mindset, and for anonymous conversations on the internet, that's never going to be worth it. You're also unlikely to learn anything by engaging in argument as they probably don't even know the reason themselves why they believe what they do.
The second thing to think is - is it worth it? What will really happen if this person continues to believe as they do? Is whatever you can potentially learn from them even worth the time? Even if you do end up continuing the discussion, asking yourself these things can help you step back and communicate from a more collaborative, flexible place.
As other commenters have mentioned, communicating by text on the Internet is difficult to convey exactly what you meant. No matter what you write, some people are going to misinterpret you. A lot of arguments I've seen happen when both parties essentially talk past each other, quoting each other's responses but never actually engaging with each other's points. Whether because they didn't read the initial post carefully, or they basically understand the other person's points but think something else is more important so argue about that instead, while the original poster thinks that's irrelevant and continues trying to convince the replier that they're correct. Often if you came right down to it and somehow magically gave everyone a clear, semantic understanding of the content of what the other person was saying, there would be no disagreement. But these kinds of things seem to happen a lot and cause a lot of bad feelings.
The other thing is that actual disagreements about verifiable facts are rare between two reasonable people, once the relevant knowledge sources have been shared. If someone is unreasonable, just don't engage with them at all.
Much more often, each person has a certain context of personal experience which informs their opinion. When both people express their opinions through text, it can seem (to each other) like they're in conflict, when in reality the different opinions are each applicable to different situations and equally valid given each person's individual experience. This can be difficult to notice, but something to be aware of.
In summary, a process you might go through when reading something is:
1. you have a knee-jerk "that's wrong" reaction. You need to stop yourself from immediately saying something in response.
2. Carefully read (and re-read) what they actually wrote.^1 Try to interpret it charitably - based on what they did actually write, what are they actually meaning? Usually if you're in an argumentative mindset, you interpret things more adverserially than they actually are.
^1: I can't count the number of times I've started writing a response, then before I submit I go back to read the post I'm responding to, and see something I missed that makes a large part of my post irrelevant and unnecessarily negative.
3. Try to understand where they're coming from. If something isn't clear, before you do anything else ask non-confrontational questions, giving them the benefit of the doubt. If you've got to this point, probably 90% of unpleasant arguments are already avoided.
4. Put forward your viewpoint and have a discussion as normal.
5. Apply the same charitable interpretation to every response and be willing to admit when you're wrong. If the discussion is getting heated and feelings are potentially getting involved, de-escalate as fast as possible, even if that means admitting you're wrong when you don't actually believe that. (Ideally you would convey respectfully that their points have merit in some way and just leave the discussion rather than straight up lying.)
Throughout all this, remember that people other than the person you're discussing with are likely reading what you write, so even if you're failing to get through to the individual, other people may find significant value in your discussion (even if they will likely never actually reply and say so.)
Additionally, if you're behaving respectfully and setting a good example while the other person is getting emotional, other people with no emotional investment will tend to take your side even if they know literally nothing about the subject matter. There's simply no downside to making the effort to consider the other person's emotional state and mindset because it makes the experience better for everyone.
I try to approach most online discussion from a perspective of understanding rather than trying to convince, argue, or prove something. This also directly aligns with the goal of learning, because, well, that's what I'm trying to do.
The first thing it helps to realise is that every individual is at a different level of understanding. Not everyone cares that much about learning & understanding, so often people are just repeating things they've heard and internalised. It takes work and time to "unstick" people who are like this from their current mindset, and for anonymous conversations on the internet, that's never going to be worth it. You're also unlikely to learn anything by engaging in argument as they probably don't even know the reason themselves why they believe what they do.
The second thing to think is - is it worth it? What will really happen if this person continues to believe as they do? Is whatever you can potentially learn from them even worth the time? Even if you do end up continuing the discussion, asking yourself these things can help you step back and communicate from a more collaborative, flexible place.
As other commenters have mentioned, communicating by text on the Internet is difficult to convey exactly what you meant. No matter what you write, some people are going to misinterpret you. A lot of arguments I've seen happen when both parties essentially talk past each other, quoting each other's responses but never actually engaging with each other's points. Whether because they didn't read the initial post carefully, or they basically understand the other person's points but think something else is more important so argue about that instead, while the original poster thinks that's irrelevant and continues trying to convince the replier that they're correct. Often if you came right down to it and somehow magically gave everyone a clear, semantic understanding of the content of what the other person was saying, there would be no disagreement. But these kinds of things seem to happen a lot and cause a lot of bad feelings.
The other thing is that actual disagreements about verifiable facts are rare between two reasonable people, once the relevant knowledge sources have been shared. If someone is unreasonable, just don't engage with them at all.
Much more often, each person has a certain context of personal experience which informs their opinion. When both people express their opinions through text, it can seem (to each other) like they're in conflict, when in reality the different opinions are each applicable to different situations and equally valid given each person's individual experience. This can be difficult to notice, but something to be aware of.
In summary, a process you might go through when reading something is:
1. you have a knee-jerk "that's wrong" reaction. You need to stop yourself from immediately saying something in response.
2. Carefully read (and re-read) what they actually wrote.^1 Try to interpret it charitably - based on what they did actually write, what are they actually meaning? Usually if you're in an argumentative mindset, you interpret things more adverserially than they actually are.
^1: I can't count the number of times I've started writing a response, then before I submit I go back to read the post I'm responding to, and see something I missed that makes a large part of my post irrelevant and unnecessarily negative.
3. Try to understand where they're coming from. If something isn't clear, before you do anything else ask non-confrontational questions, giving them the benefit of the doubt. If you've got to this point, probably 90% of unpleasant arguments are already avoided.
4. Put forward your viewpoint and have a discussion as normal.
5. Apply the same charitable interpretation to every response and be willing to admit when you're wrong. If the discussion is getting heated and feelings are potentially getting involved, de-escalate as fast as possible, even if that means admitting you're wrong when you don't actually believe that. (Ideally you would convey respectfully that their points have merit in some way and just leave the discussion rather than straight up lying.)
Throughout all this, remember that people other than the person you're discussing with are likely reading what you write, so even if you're failing to get through to the individual, other people may find significant value in your discussion (even if they will likely never actually reply and say so.)
Additionally, if you're behaving respectfully and setting a good example while the other person is getting emotional, other people with no emotional investment will tend to take your side even if they know literally nothing about the subject matter. There's simply no downside to making the effort to consider the other person's emotional state and mindset because it makes the experience better for everyone.