It's best to throw out all these value judgements.
Evolution isn't purely random. There's nothing random about what works and what doesn't. Over time, differential selection and other effects (e.g. sexual selection) work to transfer information about the environment into the genome. Evolution is a learning process. It's just that the representation that it generates is difficult for us linear thinkers to interpret.
It only appears irrational from an anthropocentric point of view. It's not rational to us because we, having brains that work in a certain way, are biased toward seeing things as linear chains of cause and effect. That's how we think and that's how we like to build stuff, but obviously that's not the only way stuff can be built.
For all we know elsewhere in the universe there are beings that think in massively parallel super-holistic causality-matrix terms. To them evolution's designs would seem perfectly rational, while a UML block diagram would seem insane. "Nothing has only one cause or one effect," they would mutter... in a language in which every word implies everything to varying degrees and each syllable of a sentence must be parsed in parallel with all others.