It's not illegal or even immoral for a President to make requests which may have the side effect of effecting elections. Everything, after all, can potentially effect elections.
What a candidate (including an incumbent President) cannot do is request a foreign national something "of value" to his campaign. This may seem like a play on words, but that is not the same as something of benefit to his campaign. This has been explored in some detail in this law.SE question.
Requesting an investigation of a corrupt or a criminal matter is not, in itself, either a crime or even immoral. Even if it benefits his campaign, it's still something that any honest man should welcome. It does not fall within the boundaries of what is prohibited as an in-kind donation of "something of value".
As the person tasked with executing laws, it is doubly-so a President's job to ensure that criminal matters involving US citizens abroad are properly investigated.
Despite the fact that it is "all too convenient", the fact that his personal interests may align with his professional responsibilities in this particular case, does not mean that this President should be avoiding his responsibility of ensuring that a potentially criminal matter is investigated.
Could he make the request to the DOJ?
If he is aware of any reason to investigate someone who is a political rival, he must make the request to investigate. This comes with the job of being the executive branch of the US government. Running for President is not a carte blanche to commit crimes or to have a clean slate for any previous crimes. Any potential candidate who may need to be investigated should be. No one is above the law.
Could he make a request to a foreign government?
Assuming the United States recognizes this foreign government as having sufficiently advanced legal system to investigate crimes and assuming that the US government expects such an investigation to be conducted fairly, yes. Since the US has treaties with Ukraine which outline steps for mutual cooperation in investigating criminal matters, the US government does treat Ukraine as a competent partner in such matters.