The main reason online casino choose to hand out bonus codes is that players can use them whenever THEY choose. This of course makes things far more practical from the players side as they can utilise bonus codes when they are ready instead of giving them some free spins and forcing them to use it then and there.
Another reason is that bonus codes can be assigned to specific players. Should a casino wish to reward a specific player, through their loyalty program, the use of a bonus code ensures that only they are entitled to the promotion. This is very important to casinos as these bonus codes are quite expensive for the overall cost of operations.
Lastly, the fact that these codes are a significant operation cost for online casinos means that it would actually be in the interest of the casino if the player did not use the code. Automatically awarding these bonuses to players would instantly set the casino back a few pennies. By using promotional codes the casino understands the possibility of players ignoring or simply choosing not to use the bonus . In this way the casino saves some costs.