ATC will give you the best direct routing available most of the time. If you are then told to maintain the heading it will be to separate you against other traffic at or going through your level. The lateral separation limits don't change whether you are on a heading or not but when Radar Separation is applied separation has to be ensured, hence the use of headings. If you are given a direct and immediately afterward told to continue on the heading it will be for the same reason but the controller has decided to let you pick the optimal heading to your way point rather than estimate it him or herself. It’s a good method if the waypoint is a long way off or there is a strong wind playing havoc with the holding headings. Often the traffic you are on a heading against is not on (or not yet on) the same frequency, so it will not be obvious to the flight deck what is going on.