I love when I get my guitarist to just wing it and we do plenty of different takes and I end up picking one of the (or maybe combine many) takes.
If you want the guitarist to go nuts (but obviously not playing anything that's not in the key or something that doesn't sound right), I'd just let him go all out. Let him improvise.
On the other hand, when writing more of a catchy hook which is often labeled as the guitar solo, you, of course, want to make sure it's a really catchy solo. Often something that kind of repeats (but not something that sounds repetitive) but is a catchy melody... if done correctly that can be pretty awesome.
If you check out my most recent album The Beat Demon (which can be heard on Spotify or on Bandcamp for free), there is a guitar "solo" (hook) at about 3:16. Basically my attempt was to create kind of a different guitar sound that was sort of low and dirty, but I wanted a catchy hook as well. If you're listening, the melody almost repeats itself but it in a slightly different way every time. Does that make sense? I'm not the best at explaining. I'm just giving an example there. Don't take anything I'm saying as a "line reading". Come up with something completely new and different.
Uniqueness and catchiness always help. That's what I have to say about it, but my advice is more creative-based rather than music-based, so let another guy tell you more about the technical side of it.