To replace a chain, push a pin out of the old chain and measure the new chain against the old to make sure it has the same number of links. If you have to remove links, remove them at the end without the bolt sticking out. If you have to break a chain with the intent to reinstall it, push one bolt towards the outer side of the bicycle until the link just barely holds together. Bend the chain to disengage the broken link. It's impossible to re-insert a bolt pushed out all the way. To install a chain, join the chain and push the bolt in until it is flush with the link plate, then push it back from the other side until it's as flush with the plate on that side as all the other links. Then, bend the chain sideways until it moves freely. A stiff link makes the chain skip when riding. You need a special chaintool for pushing bolts.
The chain length should be chosen so that all gear combinations are possible: if the chain is on the largest chainring and the largest cog, the rear derailleur should still have some play, and if the chain is on the smallest chainwheel and the smallest cog, it should not touch itself near the upper pulley in the rear derailleur. Of course you won't normally ride these extreme gears because of the poor chainline. If these conditions can't be met, consider changing the pulleys or chainwheels, or the rear derailleur capacity (i.e. use one with a longer cage). As a rule of thumb, the rear derailleur should be roughly vertical (both its pulleys are exactly below the axle) when the chain is on the largest chainwheel and the smallest cog.
In case of doubt I prefer a shorter chain because this increases its tension and makes it less likely to bounce and hit the chainstays (the frame tubes that connect the bottom bracket and the rear dropouts). On mountainbikes ``chain suck'' can become a problem when the chain bounces so much that it gets caught between the chainstay and the chainwheels. You can bolt little gizmos to the chainstay to prevent this, but I have seen these gizmos to cause more chainsuck problems than they solve because if the chain gets stuck anyway it gets stuck so tightly that it requires tools to make the bicycle ridable again. I am generally wary of little add-on gadgets.
See also an article on "Selecting A Gear Range"