Horses that do not know how to stand still for a farrier not only put the farrier in danger, but themselves too. Additionally you may have hard time finding a farrier willing to trim or shoe your horse if it has poor manners.
The first step is making sure your horse ties well. This includes having no signs of pulling back. If the horse has had problems with tying there are several styles of training halters designed to remedy this problem. Sack out the horse with the training halter on until the horse shows stops trying to pull back. You can also give it a smack on the rump when it does pull back. Ensure that the horse is tied safely such that it cannot break free, which would cause it to learn that it can escape if it pulls hard enough.
Your horse should be totally familiar with the word "Whoa" and should respond to it fully.
Tie your horse and spend time picking up your horses feet, hold them higher than you normally would, and for gradually longer periods of time than is needed for simple hoof cleaning. Watch a farrier and see how he holds the leg, do the same to your horse, starting slowly at first, and building up. Tap on the hoof with your knuckles to simulate different sensations they may get from a farrier. This should be done daily, before and after a ride, or work out.
Unless the horse has a foot problem, trimming and shoeing are not painful, but the farrier will be putting some pressure on the hoof in the way your horse may not have experienced before.
Reward your horse with treats when you are through, but do not keep the treats in your pocket. If you keep the treats in your pocket, the horse may become a pest as it tries to get into your pocket looking for the treats, which could be a problem for the farrier if the horse does the same to him.
Twitching a horse who is a problem is a good idea and, if only used as a measure of last resort, can help the horse overcome its fear of the farrier. Twitching does not hurt the horse in as much as it preoccupies their mind so they are not focused on the farrier. The simplest of twitch is the neck twist, where you grab an piece of skin on the side of the neck and twist it. The next twitch, which may be better used in the farrier situation, is an ear twitch, one ear is grabbed (not on ear shy horses) and twisted. A more severe twitching method, which should only be used as a last resort, is the lip twitch, in which a twitching tool with a chain is used to grab a chuck of the horses lip and twitches it for control over the horse.
It is handy to have an extra person help the farrier, they can hold the horse and try to keep it still and occupied. Having something for the horse to look at may help keep it still longer. The horse may not want to be in the barn alone when all its friends are outside, and out of sight.
Drugging a horse before a farrier visit is never a good idea, but you may wish to lunge the horse first, or give it a long work out to tire it out a bit, especially if it is a higher energy horse who does not like to stand.
Punishing a horse who is not standing is not fair to the horse, and will make it fear the farrier even more.
Farriers will typically charge more if your horse is not behaved or will refuse their services if they feel your horse is unsafe. Making sure your horse is quiet for the farrier is your job. If you ever feel a farrier is being too rough to your horse, have another horse person watch them to get their opinion, if they agree that the farrier is too rough with your horse, get different farrier.