In a battle that is continued until either the defender's armies are eliminated or the attacker's armies are reduced to 1, both the attacker and the defender maximize their chance of winning by rolling as many dice as possible. You can confirm this by taking a look at the probabilities for each possible outcome. The numbers were calculated by simply enumerating every possible roll and tallying the results (in Matlab).

This confirms that the attacker has a slight advantage in 3 vs 2 rolls. So if you're playing heads-up Risk, you're always better off attacking than defending, all other things being equal. But if there are other players involved, keep in mind that attacking and defending both lead to losing armies, while the other players look on happily, maintaining all their forces.

Now, assuming that each player rolls as many dice as possible each time, a battle is a 2-dimensional random walk on the grid of (# of attacking armies, # of defending armies). The transition probabilities can be read off the graphs above, where the number of dice that are rolled depends on the position in the grid. Now we can work out the probabilities of winning a Risk battle for any position on the grid using dynamic programming, starting at (0,0) and working outwards.

This graph shows the probability of the attacker winning a battle in Risk, as a function of the number of armies each player controls:

Here are the first 30 rows and columns, in text format (download):

Finally, here is an image of the 5%, 50%, and 95% contour lines from the graph:

The 50% (bright green) line crosses at about (45,40), which means that the attacker have a 50% chance of winning the battle if he has 40 armies and the defender has 45 armies. It is interesting that in evenly-matched battles, the defender has the advantage for small numbers of armies (due to the fact that the attacker basically has 1 useless army that must be left behind), but after about 11 vs 11, the attacker gains the advantage due to his better dice odds.