Question about the ending

I watched the last episode and it made me very confused about erens intentions. In the ending yumir is free and the Titans desapear from the world becouse of mikasa. What i want to know is, did that append to free the world from the Titan terror or did that happend so his friends would live a long life. My big question in this is, did eren did all that with the only purpose beeing to make his friends live a peacefull life? Or was that giant chain of events leading to the extinction of Titans? Becaouse if its the first options than eren values more the life of his friends that 80% of humanity whitch is very sad. I hope you would help me with this question and help me see more into erens charecter.