When you're last hitting in Dota2, a lot of the damage from creeps is being dealt by the ranged creep. Notice which enemy creep it's attacking and often simply just time your projectile to hit immediately before or immediately after the ranged creep's attack to ensure the last hit. You should be hitting each enemy creep exactly once- this way your enemies won't have a chance to deny it while you're waiting for your next attack. If your opponents are too close to the wave, especially if they're melee and you're ranged, you can harass your opponent to completely remove the ability for them to deny you. Doing this will draw creep aggression to you, however, so you should usually start to back away as soon as your attack is released to minimize the damage you'll take (none, if you've positioned properly). If you feel like you're in a good position, you can also animation cancel (begin walking towards your target) as soon as the attack is released, and usually get off more attacks and really harass your opponent. Just be careful when chasing past the creep wave, you usually don't want to expose yourself that much unless you're in a strong position and an creep wave can do a surprising amount of damage.
Your starting items will also help you to last hit in lane dramatically. My typical ranged carry build is a +3 primary stat, a +2 all stats, and three +1 all stats items, and a health potion or tangos. This gives you adequate health regeneration, +95 HP, and +8 damage, and builds nicely into a Magic Wand and a Wraith Band/Talisman. For melee carries, I usually buy a Stout Shield, a health potion, tangos, and three +1 all stats items. I see a lot of new players buy boots or other worthless items first that don't help them win the lane, they just lose it less dramatically. You'll be surprised how simple choices like this can help you crush a lane early against equally skilled opponents who are making bad choices. If you're a melee hero competing with a hard hitting melee hero or an opponent who keeps denying creeps, consider buying a Quelling Blade to improve your damage. If it lets you get 3 last hits you otherwise wouldn't and then you sell it, it's more than paid for itself.
One concept calling animation canceling is unintuitive at first but incredibly important both in lane and in general. To perfect your last hitting, you'll need to know how to do this and understand your hero's attack point. Here's a full list of Attack Points that's sortable (add the Atk Point column)- they typically are between .3 and .6 seconds, with a few outliers. A lower attack point is better because it lets you prepare an attack faster. It's kind of like riding the edge of a trigger: you want to be really close to firing as often as possible, but not actually fire until you're sure of it. When you know your hero's attack point (which will improve over the course of the game as you gain attack speed), you can start attacks and cancel the animation just before it completes by pressing S or H, immediately being able to start another attack. Doing this repeatedly is very effective for faking attacks and causing your enemy to misplay- they won't know when your true attack will be coming out. To last hit with ranged heroes you'll also have to account for projectile speed, which also varies but can be seen in the same link.
Each time you or your teammates deal any damage to the enemy creeps (in this case by last hitting them) you slightly help your creep wave to push the lane towards the enemy tower.
The best place to farm is slightly in front of your towers range of attack,so you are close to safety but without tower interfering with the creeps.
To get creeps to fight there you will have to block your creeps movement as much as you can and then actively hit and deny your creeps as soon as they get under 50% HP to help enemy creeps push the lane closer to your tower.
Once you get the creeps to fight in that spot,in order to maintain that place each time you hit the enemy creep you should hit or deny one of your creeps too.
This is known as maintaining lane or creep equilibrium.
There is also a chance that some invisible or hiding enemy hero is there trying to get EXP
Best Answer
Honestly, this has nothing to do with auto attack on or off. Or standing still for that matter. You can be constantly moving, but not be applying the side step or animation canceling technique.
There are 2 main reasons why would you would do this side stepping as you would call it.
In both Dota and Dota 2, there is a mechanic called animation canceling. When your hero attacks a unit, the damage gets inflicted upon the unit before the animation is finished. So by side stepping really quickly, and then attacking again, you are able to cancel the ending of your first attack animation and then proceed to initiate another attack animation. This is widely used in the jungle as it increases the number of attacks you can deliver in a specific period of time.
Another reason to do this side stepping is positioning. For example, let's say you are on radiant side, and at the bottom of a creep wave. But perhaps you want to be north of the creep wave and take an offensive position, while pushing the wave. The most efficient way to keep the pushing at a maximum is to hit a creep, animation cancel by taking a step forward and repeat.
EDIT: For melee heros, you side step after the damage is inflicted. For ranged heros, you side step after the projectile is released.