These three words can be used interchangeably in most situations however they do have three slightly different meanings, as follows.
* Best implies a ladder, or ranking between measurable options, where the closer to the top the better, or the higher up the ranking, the better. Similar to how the word "top" is sometimes used. Due to it being a short, simple word, "best" is used much more commonly in everyday speech than "ideal" or "optimal". It's also considered a bit over-judgemental in situations where things are hard to compare.
* Optimal has a slightly more dynamic implication - it implies a scale whereby you could shoot too high or too low, or you could scroll too far left or right - the optimal spot is not too far to either side, it's balanced in the "sweet spot". It's the least commonly used of the three words, and is often used in scientific explanations.
* Ideal usually relates to preferences and choices, and is often used a casual exaggeration, although in literal terms technically means the same as what "best" can potentially mean. Not as commonly used as "best" - it's often used in a less strict sense, whereby there are a range of options which can not be easily measured or compared (we have an idiom for this: "apples and pears"). But if an option is selected where you can't spot flaws in it, even if there may be equal or superior options, you might say "that's ideal!" as in "that's a perfect idea" which may be an exaggeration but still conveys the concept of the selection being idyllic.