This is exactly how I felt for a long time playing Dota. It wasn't until I played heavy support for a group of friends who are high tier players and I started playing against people who would punish every wrong move instantly and with people who would correct every mistake I made, that I got better. I think support is the best role to start out on, it's just as difficult to get good at as all of the other roles, but there is more margin for error, as your deaths don't matter quite as much; not that this gives you a license to feed...which I did... a lot.
The first thing you need to do is get really comfortable with at least 2 or 3 heroes, so that you aren't totally lost when your hero gets picked by the other team. Positioning is something I didn't learn properly until I started playing initiate heroes (heroes that start teamfights) like Sandking and eventually Magnus.
Sandking is a great hero to learn early. He has an instant stun, which is fairly easy to land, a brief invis to get you out of bad situations you may get into and his ulti can be game-changing if you land it properly. He's a hero that teaches you about positioning, because you have to make sure you are slightly outside of enemy sight/stun range before initiating and he's a support as well, so he teaches you about core item builds and when to pick up items such as wards and courier for your team. Try him out, see if you like him and make some plays; that's my recommendation at least, as he's easy to contribute with. Just make sure you learn how to use blink dagger with his ultimate once you get comfortable enough with him:
http://www.youtube.com/watch?v=zRVYQjwwML4
That vid will give you a decent idea of how to play the hero and teach you his fantastic initiating skills with blink dagger.
As far as knowing what to do and when to do it goes, I think everyone is constantly learning that one. Play with teammates who you can voice chat with, random pubs wont teach you how to coordinate properly with your team. Make a decision to go on a hero with your lane partner for instance, do some math, say 'yep, they're low enough that our attacks will definitely kill them' and go for it. Defending towers is important, losing too many towers is how you lose the game, not just losing team fights. The most important part of every decision you make, is carrying a TOWN PORTAL SCROLL. Always have a TP in your inventory, if you have a spare 135 gold, buy one, always. This allows you to get to towers to defend and travel to teamfights you are far away from quickly.
Also remember you can buy TP scrolls, boots and other assorted items from the sideshops in lane, which saves you time and keeps you in lane.
Item builds are really important too. Find a good core item build for a hero (lots of guides online, some are bad, some are good) and make sure you always know what item you are going for next. Don't be afraid to adjust your build though. Taking a lot of harass in-lane? Get a magic wand. Getting picked off by their high-DPS autoattacking carry, get Ghost Sceptre. Getting stunned out of every fight? Get BKB. The list goes on and you will learn item builds as you get better. The other thing is starting builds. Don't buy boots first and don't buy bottle first (there are very occasional situations where you can, but not worth mentioning here). Always get regen, 1 tango, 1 salve and 3 iron branches is the most all around item build that generally works for all heroes. If you are mid, get 1 tango and 3 iron wood branches, so you can buy your bottle faster. I wouldn't advise you play a mid role just yet though if you're a beginner, as it can be a difficult lane to play successfully. Why iron wood branches you ask? Iron branches are the most cost effective item in the game, and it's far better to get 3 of them than a slippers of agility, or a mantle of intelligence or a gauntlets of strength,as you get the same stats for less money and you can turn the 3 branches into a magic wand later (which is good on basically every hero and gives you a burst heal that can get you out of bad situations).
This vid talks about starting item builds and why they are important. It's long though, but you can skim through and get the gist of it:
http://www.youtube.com/watch?v=8k6XM4MlYts
Purge does lots of videos helping new players out, so watching him could be a good idea as well. Watching pro games is good also, as you will see interesting strats and item builds and fantastic play and positioning that you can learn from.
If you are really stuck for things to do and neither team is pushing or fighting, but it's past the laning phase, farm jungle. Even if you are a support, gold is always important (unless you are taking it from your carry, don't do that shit) so killing jungle creeps for gold/exp is great. Also, buy wards every 6 minutes if you have the gold and are playing a support role. Don't play carry until you are confident in your skillz bro.
Seriously. Don't play carry, we don't need another carry, those guys picked up Drow and Sniper....don't pick a carry...really? You picked Nightstalker? You want to lane him? Oh come on man. Sorry just venting...
Hope that essay helped a bit...
Good luck!