Attack On Titan penultimate chapter 138 shows the role of Mikasa in the story's ending. Mikasa's action has divided the community a little, because some people didn't like why Mikasa did what she did. I will try to explain the rationale behind her decision. Moreover, I didn't realize until this chapter that how important Mikasa words and feelings were for Eren and how it will change the Attack on Titan world.
Before reading this, firstly, you need to understand that the LONG DREAM we witnessed in this chapter was in fact not a dream. It was an alternative reality where Mikasa and Eren decided to be together. Secondly, the Attack Titan has the ability to tell its host what has happened before. This is very important because this explains Eren's sudden change in behavior.
From Eren perspective, at one point in the story, possibly where his actions starts to make no sense to Armin, Mikasa, and Survery Corps, he figures out what would happen if he didn't do something drastic. He would live a happy life with Mikasa but things would remain the same. The curse of titan would remain and the vicious cycle of hatred would continue. He didn't want any of that and decides to go against it by becoming a monster the world has never seen before. However, even though he knows what to do, he wasn't sure in which direction the things were moving. He needed someone to change things and that someone was Mikasa. A perfect candidate because of being an Ackerman.
"What am I to you?" asks Eren. "You... are a family" says Mikasa. This is where he realizes that he can change things, and do things differently. This is not what Attack Titan showed to him, and from here on forward we saw a different Eren.
Now coming back to this chapter from Mikasa's perspective. The dream we saw actually happened. It is not the case of what Mikasa wants or what Eren wants Mikasa to believe. This very important to understand because this is what Attack Titan showed to Eren and now Eren is showing to Mikasa. During this so called long dream, Mikasa becomes the second person to witness the reality that has already happen before. She now completely understands why Eren did what he did and why she's the one to kill him. This is why she keeps the red scarf that Eren gave her even after killing her. She knows the truth.
In short, Eren and Mikasa are the two people who have seen both the timelines, and the both came to the conclusion that Eren death is what the world wants. Even though, it goes against their personal feelings.