This is one of those fuzzy math problems like “How many piano tuners are there in New York?”. None of the exact figures are known with any fine degree of precision but the result should be reasonably correct if you make some good educated guesses.
The biggest problem isn’t guessing the total number of males that have ever been born because that has been worked out about as well as can be estimated today. It is figuring out how many of them ever produced any sperm at all and, of those that did, how long did they? Infant mortality was a huge issue throughout much of human history and a very significant percentage of males never made it to puberty and, of those that did, many others didn’t last very long after that.
You can start with 50 billion total males as a reasonable figure but the number of those that produced sperm at all is much lower than that (possibly close to half over all places and periods; I am also using the 1/2 to correct for things like infertility and very early death in young adulthood). Those that were left had a lower life expectancy than males today but not as much as most people thing so I will treat them as roughly equal.
Total lifetime sperm production for a modern male is about 500 billion.
Therefore, once you correct for life expectancy, the approximate answer is just 500 billion * 25 billion = 1.25e+22. That is undoubtedly not the exact answer but it should be correct within an order of magnitude.