Is it weak writing to have an evil character have the motivation of getting killed by the main character? Let's say his life goal is getting killed by the main character for the sake of getting killed by the main character, not to achieve something, but getting killed by the main character is the goal itself. Is that weak writing? If so, what can you do in order to make the writing good without changing that element. If it's not possible, can you explain why having a "good" or "legitimate" motivation is absolutely crucial to good writing?
Such a motivation is deeply unusual.
As a consequence, it would need a lot of development and demonstration to be convincing. Why on earth did the character decide that this is his goal? What is his motive for choosing it? Is it an Absurdist decision to mock the absurdity of the universe by choosing an arbitrary goal and stick to it as if it had meaning?
As a rule, the more unusual a motive, the more justification needed. If a woman's sister took an interest in her fiance, we would need very little to believe the woman tries to keep them apart, but a lot to believe that she pushed them together. And this makes encouraging your sister and your fiance to get together look commonplace.
Is that weak writing?
While implementation is still king, and a really good execution of even a weak premise can still be good - yes that's pretty weak. In fact this is precisely the sort of premise my old writing tutor would have set as an exercise to teach that you can't rely on a good premise to carry bad writing.
Is it weak writing to have an evil character have the motivation of getting killed by the main character? Let's say his life goal is getting killed by the main character for the sake of getting killed by the main character, not to achieve something, but getting killed by the main character is the goal itself.
The section I've bolded above is the crux of the problem here. I can think of all kinds of scenarios where one character might aim to contrive a situation where another kills them in order to achieve a goal - e.g. getting the unwitting killer arrested and sent to jail in lieu of a murder they got away with, or a villain trying to push a hero to murder to prove they aren't as righteous as they claim to be etc. But for no reason other than itself? It's nonsensical and frankly not particularly interesting.
If so, what can you do in order to make the writing good without changing that element.
You could do a really first-class job of telling that story but it's always going to come with that caveat of it being a great telling of a poor story.
If it's not possible, can you explain why having a "good" or "legitimate" motivation is absolutely crucial to good writing?
Because someone doing something for literally no reason isn't interesting - I'm not saying that the reason needs to be obvious, indeed some of the best motivations aren't, and finding out why a character has a certain goal or why they do something is a great way of keeping a reader interested and provides a great tool for giving a character depth. Because the vast majority of deliberate human actions are done for a reason, even if that reason is one that's alien to our own thought processes - so characters and actions that lack this are likely to come across as incredibly one-dimensional and un-relatable.
If you're determined to keep that plot point as immutable the best approach would be to leave the characters motivations ambiguous if done correctly this can be very effective, particularly where the intent is to actually dehumanize the character. Take the example of the villain Micheal Myers from the original 1978 version of Halloween, here we have a villain whose sole motivation for killing babysitters is that.. well he wants to kill babysitters. That's it - the movie never provides a goal or motivation beyond that which serves to further the scariness of the killer and the notion that they're a personification of evil itself.
I still think you'd have to come up with a pretty clever implementation of them trying to get the main character to kill them to make it work - and you'd need some general notion of what you were wanting the reader to take from it.
I feel you could do a lot of interesting things with the basic premise that the evil guy wants to die at the hands of the hero. But there needs to be an explanation that will satisfy the readers.
Maybe the bad guy doesn't want to be evil, but can't control himself. But he can manipulate events to get himself killed, and stop himself that way.
Maybe the bad guy is a weird alien, and needs to be blasted with a lethal dose of exotic radiation for the eggs he's carrying to hatch, and only the super-hero of the day can do that.
Maybe the bad guy is dying of something far worse than the quick death the hero would provide.
Maybe the bad guy is just tired of life because his girlfriend left him and wants to go out in the coolest way they can think of.
Maybe he hates the hero's holier-than-thou attitude so much, that he wants to get blood on the hero's hands, any blood, even their own.
There's lots of ways that you can make "the bad guy wants to be killed by the hero" more interesting than "for no reason at all". The latter would just leave the reader wondering "but... why?" At the end of the story, everything should make perfect sense in hindsight. (Except perhaps for things left for the sequel.)
I've seen it done once, but even then it was quickly resolved in the heroes making the evil character into an ally.
In Super Sentai's (Japanese Power Rangers) 38th season Ressa Sentai ToqGer, the villain Zaram's story pits him as one such character. He starts our as a fairly high ranking member of the villain faction, but saw the error of his ways and wishes to atone. To his mind, this involves either his own death while committing a noble deed OR his death at the hands of good aligned people. Naturally, this brings him to confront the rangers, specifically wishing they would kill him for his crimes (which are minor in nature... but at the same time did help the villains advance their plot). However, the Red Ranger of this season sees that the "villain" is truly remorseful for his actions and decides not to kill him, but let him atone by becoming the teams Sixth Ranger and joining them (the story is notable in that while there were many antagonistic sixth rangers in the past, they were either brainwashed or they were sincerely believing that opposing the rangers was a good action. Zaram was the first guy who was part of the villain faction and realized they were evil without the rangers intervention. He was jut never believed he was worthy of forgiveness and could atone without dying for his sins.).
In most other times, it's due to the hero and villain being fated that one shall live and one shall die. Here, the villain's motivation isn't so much that he wants to die, as it is that this fight needs to happen and if the hero wins, he is at peace with his death. A lesser version can be in competitions where the villain may understand that the hero is the better character to win, but they have to have a match to determine which one will win and the villain will not go easy on the hero for the sake of sportsmanship.