The direct object is what you learn from him and the indirect object is he himself. And:
ihm is dative case because von requires the dative case.
(mizinamo already explained that in this very comment section.)
Example sentence which uses both objects:
- "Ich lerne Schreiben von ihm." = "I learn writing from him"
- "Ich lerne von ihm zu schreiben." = "I learn to write from him."
I still feel it’s very confusing because I feel like “he” should be the subject since he’s giving you a lesson or something along those lines... Couldn’t you write him as the subject, what he’s teaching as direct object and I/me as the indirect object? Like, “Er lehrt mir zu schreiben”?
I feel like “he” should be the subject
It always on whose action you're focusing on. Do you think that you, as a learner of the German language, don't do something actively to achieve your goal? Is Duolingo the one doing 'his' work 'on' you?
“Er lehrt mir zu schreiben”
This sentence is correct, but outdated (and thus it won't sound right to many Germans correct). You can say "Er lehrt mich zu schreiben."/"Er lehrt mich Schreiben." Nowadays "Lehren" is one of very few verbs which get two accusative objects, so it's really not the easiest word for learners.
The most common way to say it is:
"Er bringt mir bei zu schreiben."/"Er bringt mir Schreiben bei." that uses the verb "Beibringen" which is seperable.
I think you used the wrong conjugation. It could be "You learn from him", but not "You learns from him" :)
As for how to differentiate, it's difficult to explain. I think "learning" and the other -ing words are more common in speech, and you might say "You learn from him" in the context of naming when this happens. For example, "You learn from him on Sundays" would be a common sentence.
Don't worry about this too much because both forms are acceptable and correct in nearly any situation.