When Thor was in the Guardians' spaceship in Avengers: Infinity War he has his eye back.
Where did this eye come from?
Rocket Raccoon gave Thor a new eye ball to replace his missing one.
Rocket: Well, if fate does want you to kill that crapsack, you’re gonna need more than one stupid eyeball.
Thor: What's this?
Rocket: What's it look like? Some jerk lost a bet with me in Contraxia.
Thor: He gave you his eye?
Rocket: No, he gave me 100 credits. I snuck in his room later that night and stole his eye.
We know from both Guardians of the Galaxy volumes 1 and 2 that Rocket has a thing for keeping other people's body parts; in part 1 he gets another inmates prosthetic leg, and in part 2 he wants to keep an eyeball that Groot accidentally brought to him, simply because he thinks it is funny. He also mentions in Infinity War that he wants Bucky's arm.
While it is possible that the eyeball in Infinity War is the same one from Guardians of the Galaxy Volume 2, I do not think that this is likely; because Rocket states where he got the eyeball, and that story is not what happened in Volume 2. It does not seem likely that he would be lying. He admits to having stolen the eyeball, so why would he lie about who he stole it from and where?
Also, the eyeball that is stolen in Volume 2 is green; while the eyeball he gives Thor in Infinity War appears to be blue.
That could be Vorker's eye which was stolen by Baby Groot because of mis-communication in Guardians of the Galaxy Vol. 2:
So I assumed it's Vorker's eye which Rocket Raccoon gave a to Thor in Avengers: Infinity War but this one is of different colour then Vorker's eye and if we believe Rocket then it can be some other person's eye he stole from Contraxia, here is the scene from it:
And having that eyepatch was not as easy as it seems, as said by Chris himself:
It was... yeah, I remembered being... with the eyepatch, the story unrolling, 'Yeah, cool, this is interesting.' And then the day that we put the eyepatch on I was like, 'This is ridiculous.' The thing kept falling off, and we didn't have the thing [gestures an eyepatch strap]. So it became a CG eyepatch, which I was stoked about... But I'm happy with that trade [for the wig]. It has its downsides. But the upside is that it's an hour less in hair and makeup without the wig on.- cinemablend
So they don't have to do that CGI eyepatch anymore.
If you are asking about the eye, it's not Thor's eye... It was just an eye that Rocket lent to Thor based on this dialogue...
Rocket: Well, if fate does want you to kill that crapsack, you’re going to need more than one stupid eyeball.
[he gives Thor an eyeball]
Thor: What’s this?
Rocket: What’s it look like? Some jerk lost a bet with me in Contraxia.
Thor: He gave you his eye?
Rocket: No, he gave me a hundred credits. I snuck into his room later that night and stole his eye.
Thor: Thank you, sweet rabbit.
[Thor puts the eyeball into his empty eye socket]
Rocket: Ooh. I would’ve washed that. The only way I could sneak it off Contraxia was on my…
This also explains the origins of the eye where Rocket "acquired" said eye from a bet...