Remove the guitar and look at the music
Seriously, step away from the guitar. It's limiting your conception of the problem.
The problem isn't that you can't write a good guitar solo. It's that you can't write a good tune. Whether that tune is played on guitar or Mongolian noise flute is irrelevant. When you get good at working out a tune that fits, you'll be able to create solos - but you can't start with technique and work backwards to get a solo. At best, technique lets you know a few options you can use in solos, but it can't create a solo.
Start with your voice
The obvious way to start is to hum a tune. You might not be able to do the same speed, but it doesn't matter. The most important "solo" in a song is the hook riff, and those almost universally are hummable. Keep thinking, and keep humming along to songs to come up with hook or backing riffs. Record them, play them back, and see if you like them. You don't have to be a great singer, because you're not listening back for the singing quality, you're listening for the intent in the riff.
And then when you've got a tune, you need to be able to translate it to your fingers. That's harder than it sounds, because whilst muscle memory is your friend for learning patterns, it is absolutely the enemy for new ideas. So having got the hang of humming riffs, a great exercise is to hum your riff and play the same notes on the guitar. Hum each note and play that note on the guitar. And only that note - don't throw in extra hammer-ons and pentatonic frills around it and things like that, because that's using unimaginative muscle memory instead of musical imagination.
This is remarkably hard to do, but it's really good practise. This exercise forces your brain to set up the same link between tune and fingers that you already have between tune and voice. We can all hum tunes instinctively, but the mark of a good player is to be able to play tunes instinctively on your instrument the same way. Some old blues guitarists used to do this routinely, and you'll hear them in the recordings singing their guitar melody line as they play.
Keep in the zone
Don't rush your riffs. If you can only play imaginative, melodic riffs more slowly when you're starting, that's fine. Just keep in the zone where it's your musical imagination and "humming" guiding your fingers, and not muscle memory to throw in the same unimaginative thing you've done a million times before. As with all things musical, the more you do it, the more able you'll get at doing it faster. Look at the intro to The Prophecy by Iron Maiden, for instance - it's not fast, but it's super effective.